chiark / gitweb /
Add back the ultimaker platform, and made the platform mesh simpler.
[cura.git] / Cura / slice / cura_sf / fabmetheus_utilities / geometry / manipulation_matrix / _scale.py
1 """
2 Boolean geometry scale.
3
4 """
5
6 from __future__ import absolute_import
7
8 from fabmetheus_utilities.geometry.creation import solid
9 from fabmetheus_utilities.geometry.geometry_utilities import matrix
10 from fabmetheus_utilities.vector3 import Vector3
11
12
13 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
14 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
15 __date__ = '$Date: 2008/02/05 $'
16 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
17
18
19 globalExecutionOrder = 340
20
21
22 def getManipulatedGeometryOutput(elementNode, geometryOutput, prefix):
23         "Get equated geometryOutput."
24         scalePoints( elementNode, matrix.getVertexes(geometryOutput), prefix )
25         return geometryOutput
26
27 def getManipulatedPaths(close, elementNode, loop, prefix, sideLength):
28         "Get equated paths."
29         scalePoints( elementNode, loop, prefix )
30         return [loop]
31
32 def getNewDerivation(elementNode, prefix, sideLength):
33         'Get new derivation.'
34         return ScaleDerivation(elementNode)
35
36 def manipulateElementNode(elementNode, target):
37         "Manipulate the xml element."
38         derivation = ScaleDerivation(elementNode)
39         if derivation.scaleTetragrid == None:
40                 print('Warning, scaleTetragrid was None in scale so nothing will be done for:')
41                 print(elementNode)
42                 return
43         matrix.setAttributesToMultipliedTetragrid(target, derivation.scaleTetragrid)
44
45 def processElementNode(elementNode):
46         "Process the xml element."
47         solid.processElementNodeByFunction(elementNode, manipulateElementNode)
48
49 def scalePoints(elementNode, points, prefix):
50         "Scale the points."
51         scaleVector3Default = Vector3(1.0, 1.0, 1.0)
52         scaleVector3 = matrix.getCumulativeVector3Remove(scaleVector3Default.copy(), elementNode, prefix)
53         if scaleVector3 == scaleVector3Default:
54                 return
55         for point in points:
56                 point.x *= scaleVector3.x
57                 point.y *= scaleVector3.y
58                 point.z *= scaleVector3.z
59
60
61 class ScaleDerivation(object):
62         "Class to hold scale variables."
63         def __init__(self, elementNode):
64                 'Set defaults.'
65                 self.scaleTetragrid = matrix.getScaleTetragrid(elementNode, '')