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.
10 from fabmetheus_utilities.geometry.creation import extrude
11 from fabmetheus_utilities.geometry.creation import lineation
12 from fabmetheus_utilities.geometry.creation import solid
13 from fabmetheus_utilities.geometry.creation import teardrop
14 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
15 from fabmetheus_utilities.geometry.solids import triangle_mesh
16 from fabmetheus_utilities.vector3 import Vector3
17 from fabmetheus_utilities import euclidean
21 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
22 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
23 __date__ = '$Date: 2008/02/05 $'
24 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
27 def getGeometryOutput(derivation, elementNode):
28 "Get vector3 vertexes from attribute dictionary."
29 if derivation == None:
30 derivation = DrillDerivation(elementNode)
32 teardrop.addNegativesByRadius(elementNode, derivation.end, negatives, derivation.radius, derivation.start)
33 return solid.getGeometryOutputByManipulation(elementNode, negatives[0])
35 def getGeometryOutputByArguments(arguments, elementNode):
36 "Get vector3 vertexes from attribute dictionary by arguments."
37 evaluate.setAttributesByArguments(['radius', 'start', 'end'], arguments, elementNode)
38 return getGeometryOutput(None, elementNode)
40 def getNewDerivation(elementNode):
42 return DrillDerivation(elementNode)
44 def processElementNode(elementNode):
45 "Process the xml element."
46 solid.processElementNodeByGeometry(elementNode, getGeometryOutput(None, elementNode))
49 class DrillDerivation:
50 "Class to hold drill variables."
51 def __init__(self, elementNode):
53 self.elementNode = elementNode
54 self.end = evaluate.getVector3ByPrefix(Vector3(0.0, 0.0, 1.0), elementNode, 'end')
55 self.start = evaluate.getVector3ByPrefix(Vector3(), elementNode, 'start')
56 self.radius = lineation.getFloatByPrefixBeginEnd(elementNode, 'radius', 'diameter', 1.0)
57 size = evaluate.getEvaluatedFloat(None, elementNode, 'size')
59 self.radius = 0.5 * size