chiark / gitweb /
Add back the ultimaker platform, and made the platform mesh simpler.
[cura.git] / Cura / slice / cura_sf / fabmetheus_utilities / geometry / manipulation_meta / _copy.py
1 """
2 Boolean geometry copy.
3
4 """
5
6 from __future__ import absolute_import
7
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
13
14
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'
19
20
21 def getNewDerivation(elementNode):
22         'Get new derivation.'
23         return CopyDerivation(elementNode)
24
25 def processElementNode(elementNode):
26         'Process the xml element.'
27         processElementNodeByDerivation(None, elementNode)
28
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:')
35                 print(elementNode)
36                 return
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:
50                 return
51         if len(elementNode.xmlObject.getPaths()) > 0:
52                 lineation.processElementNode(elementNode)
53                 return
54         geometryOutput = elementNode.xmlObject.getGeometryOutput()
55         if geometryOutput == None:
56                 return
57         solidMatchingPlugins = solid.getSolidMatchingPlugins(elementNode)
58         if len(solidMatchingPlugins) == 0:
59                 return
60         geometryOutput = solid.getGeometryOutputByManipulation(elementNode, geometryOutput)
61         elementNode.xmlObject.transformGeometryOutput(geometryOutput)
62         lineation.removeChildNodesFromElementObject(elementNode)
63         elementNode.getXMLProcessor().convertElementNode(elementNode, geometryOutput)
64
65
66 class CopyDerivation(object):
67         "Class to hold copy variables."
68         def __init__(self, elementNode):
69                 'Set defaults.'
70                 self.target = evaluate.getElementNodeByKey(elementNode, 'target')