Package fabmetheus_utilities :: Package geometry :: Package geometry_utilities :: Package evaluate_elements :: Module setting
[hide private]
[frames] | no frames]

Source Code for Module fabmetheus_utilities.geometry.geometry_utilities.evaluate_elements.setting

  1  """ 
  2  Boolean geometry utilities. 
  3   
  4  """ 
  5   
  6  import math 
  7   
  8   
  9  __author__ = 'Enrique Perez (perez_enrique@yahoo.com)' 
 10  __credits__ = 'Art of Illusion <http://www.artofillusion.org/>' 
 11  __date__ = '$Date: 2008/02/05 $' 
 12  __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html' 
 13   
 14   
15 -def _getAccessibleAttribute(attributeName, xmlElement):
16 'Get the accessible attribute.' 17 if attributeName in globalGetAccessibleAttributeSet: 18 return getattr(Setting(xmlElement), attributeName, None) 19 return None
20
21 -def getCascadeFloatWithoutSelf(defaultFloat, key, xmlElement):
22 'Get the importRadius.' 23 if key in xmlElement.attributeDictionary: 24 value = xmlElement.attributeDictionary[key] 25 functionName = 'get' + key[0].upper() + key[1 :] 26 if functionName in value: 27 if xmlElement.parentNode == None: 28 return defaultFloat 29 else: 30 xmlElement = xmlElement.parentNode 31 return xmlElement.getCascadeFloat(defaultFloat, key)
32
33 -def getImportRadius(xmlElement):
34 'Get the importRadius.' 35 if xmlElement == None: 36 return 0.6 37 return getCascadeFloatWithoutSelf(1.5 * getLayerThickness(xmlElement), 'importRadius', xmlElement)
38
39 -def getInteriorOverhangAngle(xmlElement):
40 'Get the interior overhang support angle in degrees.' 41 return getCascadeFloatWithoutSelf(30.0, 'interiorOverhangAngle', xmlElement)
42
43 -def getInteriorOverhangRadians(xmlElement):
44 'Get the interior overhang support angle in radians.' 45 return math.radians(getInteriorOverhangAngle(xmlElement))
46
47 -def getLayerThickness(xmlElement):
48 'Get the layer thickness.' 49 if xmlElement == None: 50 return 0.4 51 return getCascadeFloatWithoutSelf(0.4, 'layerThickness', xmlElement)
52
53 -def getOverhangSpan(xmlElement):
54 'Get the overhang span.' 55 return getCascadeFloatWithoutSelf(2.0 * getLayerThickness(xmlElement), 'overhangSpan', xmlElement)
56
57 -def getOverhangAngle(xmlElement):
58 'Get the overhang support angle in degrees.' 59 return getCascadeFloatWithoutSelf(45.0, 'overhangAngle', xmlElement)
60
61 -def getOverhangRadians(xmlElement):
62 'Get the overhang support angle in radians.' 63 return math.radians(getOverhangAngle(xmlElement))
64
65 -def getPrecision(xmlElement):
66 'Get the cascade precision.' 67 return getCascadeFloatWithoutSelf(0.2 * getLayerThickness(xmlElement), 'precision', xmlElement)
68
69 -def getSheetThickness(xmlElement):
70 'Get the sheet thickness.' 71 return getCascadeFloatWithoutSelf(3.0, 'sheetThickness', xmlElement)
72
73 -def getTwistPrecision(xmlElement):
74 'Get the twist precision in degrees.' 75 return getCascadeFloatWithoutSelf(5.0, 'twistPrecision', xmlElement)
76
77 -def getTwistPrecisionRadians(xmlElement):
78 'Get the twist precision in radians.' 79 return math.radians(getTwistPrecision(xmlElement))
80 81
82 -class Setting:
83 'Class to get handle xmlElements in a setting.'
84 - def __init__(self, xmlElement):
85 'Initialize.' 86 self.xmlElement = xmlElement
87
88 - def __repr__(self):
89 'Get the string representation of this Setting.' 90 return self.xmlElement
91
92 - def getImportRadius(self):
93 'Get the importRadius.' 94 return getImportRadius(self.xmlElement)
95
96 - def getInteriorOverhangAngle(self):
97 'Get the interior overhang support angle in degrees.' 98 return getInteriorOverhangAngle(self.xmlElement)
99
101 'Get the interior overhang support angle in radians.' 102 return getInteriorOverhangRadians(self.xmlElement)
103
104 - def getLayerThickness(self):
105 'Get the layer thickness.' 106 return getLayerThickness(self.xmlElement)
107
108 - def getOverhangSpan(self):
109 'Get the overhang span.' 110 return getOverhangSpan(self.xmlElement)
111
112 - def getOverhangAngle(self):
113 'Get the overhang support angle in degrees.' 114 return getOverhangAngle(self.xmlElement)
115
116 - def getOverhangRadians(self):
117 'Get the overhang support angle in radians.' 118 return getOverhangRadians(self.xmlElement)
119
120 - def getPrecision(self):
121 'Get the cascade precision.' 122 return getPrecision(self.xmlElement)
123
124 - def getSheetThickness(self):
125 'Get the sheet thickness.' 126 return getSheetThickness(self.xmlElement)
127
128 - def getTwistPrecision(self):
129 'Get the twist precision in degrees.' 130 return getTwistPrecision(self.xmlElement)
131
132 - def getTwistPrecisionRadians(self):
133 'Get the twist precision in radians.' 134 return getTwistPrecisionRadians(self.xmlElement)
135 136 137 globalAccessibleAttributes = 'getImportRadius getInteriorOverhangAngle getInteriorOverhangRadians'.split() 138 globalAccessibleAttributes += 'getLayerThickness getOverhangSpan getOverhangAngle getOverhangRadians'.split() 139 globalAccessibleAttributes += 'getPrecision getSheetThickness getTwistPrecision getTwistPrecisionRadians'.split() 140 globalGetAccessibleAttributeSet = set(globalAccessibleAttributes) 141