chiark / gitweb /
Add back the ultimaker platform, and made the platform mesh simpler.
[cura.git] / Cura / slice / cura_sf / fabmetheus_utilities / geometry / geometry_utilities / evaluate_fundamentals / measure.py
1 """
2 Boolean geometry utilities.
3
4 """
5
6 from __future__ import absolute_import
7
8 from fabmetheus_utilities import euclidean
9
10
11 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
12 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
13 __date__ = '$Date: 2008/02/05 $'
14 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
15
16
17 def _getAccessibleAttribute(attributeName):
18         'Get the accessible attribute.'
19         if attributeName in globalAccessibleAttributeDictionary:
20                 return globalAccessibleAttributeDictionary[attributeName]
21         return None
22
23 def getBoundingBoxByPaths(elementNode):
24         'Get bounding box of the transformed paths of the xmlObject of the elementNode.'
25         transformedPaths = elementNode.xmlObject.getTransformedPaths()
26         maximum = euclidean.getMaximumByVector3Paths(transformedPaths)
27         minimum = euclidean.getMinimumByVector3Paths(transformedPaths)
28         return [minimum, maximum]
29
30 def getCenterByPaths(elementNode):
31         'Get center of the transformed paths of the xmlObject of the elementNode.'
32         transformedPaths = elementNode.xmlObject.getTransformedPaths()
33         return 0.5 * (euclidean.getMaximumByVector3Paths(transformedPaths) + euclidean.getMinimumByVector3Paths(transformedPaths))
34
35 def getExtentByPaths(elementNode):
36         'Get extent of the transformed paths of the xmlObject of the elementNode.'
37         transformedPaths = elementNode.xmlObject.getTransformedPaths()
38         return euclidean.getMaximumByVector3Paths(transformedPaths) - euclidean.getMinimumByVector3Paths(transformedPaths)
39
40 def getInradiusByPaths(elementNode):
41         'Get inradius of the transformed paths of the xmlObject of the elementNode.'
42         return 0.5 * getExtentByPaths(elementNode)
43
44 def getMinimumByPaths(elementNode):
45         'Get minimum of the transformed paths of the xmlObject of the elementNode.'
46         return euclidean.getMinimumByVector3Paths(elementNode.xmlObject.getTransformedPaths())
47
48 def getMaximumByPaths(elementNode):
49         'Get maximum of the transformed paths of the xmlObject of the elementNode.'
50         return euclidean.getMaximumByVector3Paths(elementNode.xmlObject.getTransformedPaths())
51  
52
53 globalAccessibleAttributeDictionary = {
54         'getBoundingBoxByPaths' : getBoundingBoxByPaths,
55         'getCenterByPaths' : getCenterByPaths,
56         'getExtentByPaths' : getExtentByPaths,
57         'getInradiusByPaths' : getInradiusByPaths,
58         'getMaximumByPaths' : getMaximumByPaths,
59         'getMinimumByPaths' : getMinimumByPaths}