Exemplo n.º 1
0
 def getPathBetween(self, loop, points):
     "Add a path between the edge and the fill."
     paths = getPathsByIntersectedLoop(points[1], points[2], loop)
     shortestPath = paths[int(
         euclidean.getPathLength(paths[1]) < euclidean.getPathLength(
             paths[0]))]
     if len(shortestPath) < 2:
         return shortestPath
     if abs(points[1] - shortestPath[0]) > abs(points[1] -
                                               shortestPath[-1]):
         shortestPath.reverse()
     loopWiddershins = euclidean.isWiddershins(loop)
     pathBetween = []
     for pointIndex in xrange(len(shortestPath)):
         center = shortestPath[pointIndex]
         centerPerpendicular = None
         beginIndex = pointIndex - 1
         if beginIndex >= 0:
             begin = shortestPath[beginIndex]
             # with "self.edgeWidth*2.0" better "combed". See calibration file comb_test.stl .
             centerPerpendicular = intercircle.getWiddershinsByLength(
                 center, begin, self.edgeWidth * 2.0)
         centerEnd = None
         endIndex = pointIndex + 1
         if endIndex < len(shortestPath):
             end = shortestPath[endIndex]
             # with "self.edgeWidth*2.0" better "combed". See calibration file comb_test.stl .
             centerEnd = intercircle.getWiddershinsByLength(
                 end, center, self.edgeWidth * 2.0)
         if centerPerpendicular == None:
             centerPerpendicular = centerEnd
         elif centerEnd != None:
             centerPerpendicular = 0.5 * (centerPerpendicular + centerEnd)
         between = None
         if centerPerpendicular == None:
             between = center
         if between == None:
             centerSideWiddershins = center + centerPerpendicular
             if euclidean.isPointInsideLoop(
                     loop, centerSideWiddershins) == loopWiddershins:
                 between = centerSideWiddershins
         if between == None:
             centerSideClockwise = center - centerPerpendicular
             if euclidean.isPointInsideLoop(
                     loop, centerSideClockwise) == loopWiddershins:
                 between = centerSideClockwise
         if between == None:
             between = center
         pathBetween.append(between)
     return pathBetween
Exemplo n.º 2
0
 def getPathBetween(self, loop, points):
     "Add a path between the edge and the fill."
     paths = getPathsByIntersectedLoop(points[1], points[2], loop)
     shortestPath = paths[int(euclidean.getPathLength(paths[1]) < euclidean.getPathLength(paths[0]))]
     if len(shortestPath) < 2:
         return shortestPath
     if abs(points[1] - shortestPath[0]) > abs(points[1] - shortestPath[-1]):
         shortestPath.reverse()
     loopWiddershins = euclidean.isWiddershins(loop)
     pathBetween = []
     for pointIndex in xrange(len(shortestPath)):
         center = shortestPath[pointIndex]
         centerPerpendicular = None
         beginIndex = pointIndex - 1
         if beginIndex >= 0:
             begin = shortestPath[beginIndex]
             centerPerpendicular = intercircle.getWiddershinsByLength(center, begin, self.edgeWidth)
         centerEnd = None
         endIndex = pointIndex + 1
         if endIndex < len(shortestPath):
             end = shortestPath[endIndex]
             centerEnd = intercircle.getWiddershinsByLength(end, center, self.edgeWidth)
         if centerPerpendicular == None:
             centerPerpendicular = centerEnd
         elif centerEnd != None:
             centerPerpendicular = 0.5 * (centerPerpendicular + centerEnd)
         between = None
         if centerPerpendicular == None:
             between = center
         if between == None:
             centerSideWiddershins = center + centerPerpendicular
             if euclidean.isPointInsideLoop(loop, centerSideWiddershins) == loopWiddershins:
                 between = centerSideWiddershins
         if between == None:
             centerSideClockwise = center - centerPerpendicular
             if euclidean.isPointInsideLoop(loop, centerSideClockwise) == loopWiddershins:
                 between = centerSideClockwise
         if between == None:
             between = center
         pathBetween.append(between)
     return pathBetween