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