chiark / gitweb /
4b997d796726a979a1a4c14b4b07876ab95e1d9d
[cura.git] / Cura / fabmetheus_utilities / geometry / manipulation_shapes / mirror.py
1 """
2 Add material to support overhang or remove material at the overhang angle.
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 solid
11 from fabmetheus_utilities.geometry.geometry_tools import face
12 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
13 from fabmetheus_utilities.geometry.geometry_utilities import matrix
14 from fabmetheus_utilities.geometry.manipulation_shapes import flip
15 from fabmetheus_utilities.geometry.solids import triangle_mesh
16 from fabmetheus_utilities.vector3 import Vector3
17 from fabmetheus_utilities import euclidean
18
19
20 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
21 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
22 __date__ = '$Date: 2008/02/05 $'
23 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
24
25
26 globalExecutionOrder = 200
27
28
29 def getManipulatedGeometryOutput(elementNode, geometryOutput, prefix):
30         'Get equated geometryOutput.'
31         flippedGeometryOutput = triangle_mesh.getGeometryOutputCopy(geometryOutput)
32         flip.flipPoints(elementNode, matrix.getVertexes(flippedGeometryOutput), prefix)
33         if flip.getShouldReverse(elementNode, prefix):
34                 flippedFaces = face.getFaces(flippedGeometryOutput)
35                 for flippedFace in flippedFaces:
36                         flippedFace.vertexIndexes.reverse()
37         return {'union' : {'shapes' : [flippedGeometryOutput, geometryOutput]}}
38
39 def getManipulatedPaths(close, elementNode, loop, prefix, sideLength):
40         'Get flipped paths.'
41         return [loop + flip.getFlippedLoop(elementNode, euclidean.getPathCopy(loop), prefix)]
42
43 def getNewDerivation(elementNode, prefix, sideLength):
44         'Get new derivation.'
45         return evaluate.EmptyObject()
46
47 def processElementNode(elementNode):
48         'Process the xml element.'
49         solid.processElementNodeByFunctionPair(elementNode, getManipulatedGeometryOutput, getManipulatedPaths)