chiark / gitweb /
Add back the ultimaker platform, and made the platform mesh simpler.
[cura.git] / Cura / slice / cura_sf / fabmetheus_utilities / geometry / geometry_tools / path_elements / quadratic.py
1 """
2 Quadratic vertexes.
3
4 From:
5 http://www.w3.org/TR/SVG/paths.html#PathDataQuadraticBezierCommands
6
7 """
8
9 from __future__ import absolute_import
10
11 from fabmetheus_utilities.geometry.creation import lineation
12 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
13 from fabmetheus_utilities.vector3 import Vector3
14 from fabmetheus_utilities import svg_reader
15
16
17 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
18 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
19 __date__ = '$Date: 2008/02/05 $'
20 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
21
22
23 def getQuadraticPath(elementNode):
24         "Get the quadratic path."
25         end = evaluate.getVector3FromElementNode(elementNode)
26         previousElementNode = elementNode.getPreviousElementNode()
27         if previousElementNode == None:
28                 print('Warning, can not get previousElementNode in getQuadraticPath in quadratic for:')
29                 print(elementNode)
30                 return [end]
31         begin = elementNode.getPreviousVertex(Vector3())
32         controlPoint = evaluate.getVector3ByPrefix(None, elementNode, 'controlPoint')
33         if controlPoint == None:
34                 oldControlPoint = evaluate.getVector3ByPrefixes(previousElementNode, ['controlPoint','controlPoint1'], None)
35                 if oldControlPoint == None:
36                         oldControlPoint = end
37                 controlPoint = begin + begin - oldControlPoint
38                 evaluate.addVector3ToElementNode(elementNode, 'controlPoint', controlPoint)
39         return svg_reader.getQuadraticPoints(begin, controlPoint, end, lineation.getNumberOfBezierPoints(begin, elementNode, end))
40
41 def processElementNode(elementNode):
42         "Process the xml element."
43         elementNode.parentNode.xmlObject.vertexes += getQuadraticPath(elementNode)