chiark / gitweb /
Add back the ultimaker platform, and made the platform mesh simpler.
[cura.git] / Cura / slice / cura_sf / fabmetheus_utilities / geometry / creation / concatenate.py
1 """
2 Boolean geometry concatenation.
3
4 """
5
6 from __future__ import absolute_import
7
8 from fabmetheus_utilities.geometry.creation import lineation
9 from fabmetheus_utilities.geometry.geometry_tools import path
10 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
11 from fabmetheus_utilities import euclidean
12
13
14 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
15 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
16 __date__ = '$Date: 2008/02/05 $'
17 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
18
19
20 def getGeometryOutput(derivation, elementNode):
21         'Get triangle mesh from attribute dictionary.'
22         if derivation == None:
23                 derivation = ConcatenateDerivation(elementNode)
24         concatenatedList = euclidean.getConcatenatedList(derivation.target)[:]
25         if len(concatenatedList) == 0:
26                 print('Warning, in concatenate there are no paths.')
27                 print(elementNode.attributes)
28                 return None
29         if 'closed' not in elementNode.attributes:
30                 elementNode.attributes['closed'] = 'true'
31         return lineation.getGeometryOutputByLoop(elementNode, lineation.SideLoop(concatenatedList))
32
33 def getGeometryOutputByArguments(arguments, elementNode):
34         'Get triangle mesh from attribute dictionary by arguments.'
35         return getGeometryOutput(None, elementNode)
36
37 def getNewDerivation(elementNode):
38         'Get new derivation.'
39         return ConcatenateDerivation(elementNode)
40
41 def processElementNode(elementNode):
42         'Process the xml element.'
43         path.convertElementNode(elementNode, getGeometryOutput(None, elementNode))
44
45
46 class ConcatenateDerivation(object):
47         'Class to hold concatenate variables.'
48         def __init__(self, elementNode):
49                 'Initialize.'
50                 self.target = evaluate.getTransformedPathsByKey([], elementNode, 'target')