2 Add material to support overhang or remove material at the overhang angle.
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 lineation
11 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
12 from fabmetheus_utilities.vector3 import Vector3
13 from fabmetheus_utilities import euclidean
16 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
17 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
18 __date__ = '$Date: 2008/02/05 $'
19 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
22 globalExecutionOrder = 20
25 def getBevelPath( begin, center, close, end, radius ):
27 beginComplex = begin.dropAxis()
28 centerComplex = center.dropAxis()
29 endComplex = end.dropAxis()
30 beginComplexSegmentLength = abs( centerComplex - beginComplex )
31 endComplexSegmentLength = abs( centerComplex - endComplex )
32 minimumRadius = lineation.getMinimumRadius( beginComplexSegmentLength, endComplexSegmentLength, radius )
33 if minimumRadius <= close:
35 beginBevel = center + minimumRadius / beginComplexSegmentLength * ( begin - center )
36 endBevel = center + minimumRadius / endComplexSegmentLength * ( end - center )
38 return [ beginBevel, endBevel ]
39 midpointComplex = 0.5 * ( beginBevel.dropAxis() + endBevel.dropAxis() )
40 spikeComplex = centerComplex + centerComplex - midpointComplex
41 return [ beginBevel, Vector3( spikeComplex.real, spikeComplex.imag, center.z ), endBevel ]
43 def getManipulatedPaths(close, elementNode, loop, prefix, sideLength):
47 derivation = BevelDerivation(elementNode, prefix, sideLength)
48 if derivation.radius == 0.0:
51 for pointIndex in xrange(len(loop)):
52 begin = loop[(pointIndex + len(loop) - 1) % len(loop)]
53 center = loop[pointIndex]
54 end = loop[(pointIndex + 1) % len(loop)]
55 bevelLoop += getBevelPath(begin, center, close, end, derivation.radius)
56 return [euclidean.getLoopWithoutCloseSequentialPoints(close, bevelLoop)]
58 def getNewDerivation(elementNode, prefix, sideLength):
60 return BevelDerivation(elementNode, prefix, sideLength)
62 def processElementNode(elementNode):
63 "Process the xml element."
64 lineation.processElementNodeByFunction(elementNode, getManipulatedPaths)
67 class BevelDerivation:
68 "Class to hold bevel variables."
69 def __init__(self, elementNode, prefix, sideLength):
71 self.radius = lineation.getFloatByPrefixSide(0.0, elementNode, prefix + 'radius', sideLength)