2 Boolean geometry utilities.
6 from __future__ import absolute_import
8 from fabmetheus_utilities import euclidean
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'
17 def _getAccessibleAttribute(attributeName):
18 'Get the accessible attribute.'
19 if attributeName in globalAccessibleAttributeDictionary:
20 return globalAccessibleAttributeDictionary[attributeName]
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]
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))
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)
40 def getInradiusByPaths(elementNode):
41 'Get inradius of the transformed paths of the xmlObject of the elementNode.'
42 return 0.5 * getExtentByPaths(elementNode)
44 def getMinimumByPaths(elementNode):
45 'Get minimum of the transformed paths of the xmlObject of the elementNode.'
46 return euclidean.getMinimumByVector3Paths(elementNode.xmlObject.getTransformedPaths())
48 def getMaximumByPaths(elementNode):
49 'Get maximum of the transformed paths of the xmlObject of the elementNode.'
50 return euclidean.getMaximumByVector3Paths(elementNode.xmlObject.getTransformedPaths())
53 globalAccessibleAttributeDictionary = {
54 'getBoundingBoxByPaths' : getBoundingBoxByPaths,
55 'getCenterByPaths' : getCenterByPaths,
56 'getExtentByPaths' : getExtentByPaths,
57 'getInradiusByPaths' : getInradiusByPaths,
58 'getMaximumByPaths' : getMaximumByPaths,
59 'getMinimumByPaths' : getMinimumByPaths}