コード例 #1
0
ファイル: comb.py プロジェクト: poikilos/Skeinforge50plus
 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
コード例 #2
0
ファイル: dimension.py プロジェクト: folksjos/RepG
	def getSmallestEnclosureIndex(self, point):
		'Get the index of the smallest boundary loop which encloses the point.'
		boundaryLayer = self.boundaryLayers[self.layerIndex]
		for loopIndex, loop in enumerate(boundaryLayer.loops):
			if euclidean.isPointInsideLoop(loop, point):
				return loopIndex
		return None
コード例 #3
0
ファイル: dimension.py プロジェクト: rparkins999/ReplicatorG
	def getSmallestEnclosureIndex(self, point):
		'Get the index of the smallest boundary loop which encloses the point.'
		boundaryLayer = self.boundaryLayers[self.layerIndex]
		for loopIndex, loop in enumerate(boundaryLayer.loops):
			if euclidean.isPointInsideLoop(loop, point):
				return loopIndex
		return None
コード例 #4
0
ファイル: intercircle.py プロジェクト: pavlog/skeinforge
def getInsetLoopsFromLoop(loop, radius, thresholdRatio=0.9,outsetInnerMagic=1.0):
	'Get the inset loops, which might overlap.'
	if radius == 0.0:
		return [loop]
	# figureout cw or ccw
	sum = 0;
	for index,v in enumerate(loop):
		sum+=(loop[(index+1)%len(loop)].imag-v.imag)*(loop[(index+1)%len(loop)].real+v.real)
	isInner = sum<0
	innerMagic = 1.0
	if isInner:
		innerMagic = outsetInnerMagic;
	#if isInner:
	#	arounds = getAroundsFromLoop(loop, radius, thresholdRatio)
	#else:
	#	arounds = getAroundsFromLoop(loop, radius, thresholdRatio)
	isInset = radius > 0
	insetLoops = []
	isLoopWiddershins = euclidean.isWiddershins(loop)
	arounds = getAroundsFromLoop(loop, radius, thresholdRatio,innerMagic)
	for around in arounds:
		leftPoint = euclidean.getLeftPoint(around)
		shouldBeWithin = (isInset == isLoopWiddershins)
		if euclidean.isPointInsideLoop(loop, leftPoint) == shouldBeWithin:
			if isLoopWiddershins != euclidean.isWiddershins(around):
				around.reverse()
			insetLoops.append(around)
	return insetLoops
コード例 #5
0
ファイル: triangle_mesh.py プロジェクト: 3DNogi/SFACT
def getIsPathEntirelyOutsideTriangle(begin, center, end, vector3Path):
	'Determine if a path is entirely outside another loop.'
	loop = [begin.dropAxis(), center.dropAxis(), end.dropAxis()]
	for vector3 in vector3Path:
		point = vector3.dropAxis()
		if euclidean.isPointInsideLoop(loop, point):
			return False
	return True
コード例 #6
0
ファイル: triangle_mesh.py プロジェクト: marrrry/ReplicatorG
def getIsPathEntirelyOutsideTriangle(begin, center, end, vector3Path):
	'Determine if a path is entirely outside another loop.'
	loop = [begin.dropAxis(), center.dropAxis(), end.dropAxis()]
	for vector3 in vector3Path:
		point = vector3.dropAxis()
		if euclidean.isPointInsideLoop(loop, point):
			return False
	return True
コード例 #7
0
ファイル: comb.py プロジェクト: AKAMEDIASYSTEM/ReplicatorG
def getJumpPointIfInside(boundary, otherPoint, perimeterWidth, runningJumpSpace):
	'Get the jump point if it is inside the boundary, otherwise return None.'
	insetBoundary = intercircle.getSimplifiedInsetFromClockwiseLoop(boundary, -perimeterWidth)
	closestJumpDistanceIndex = euclidean.getClosestDistanceIndexToLine(otherPoint, insetBoundary)
	jumpIndex = (closestJumpDistanceIndex.index + 1) % len(insetBoundary)
	jumpPoint = euclidean.getClosestPointOnSegment(insetBoundary[closestJumpDistanceIndex.index], insetBoundary[jumpIndex], otherPoint)
	jumpPoint = getJumpPoint(jumpPoint, otherPoint, boundary, runningJumpSpace)
	if euclidean.isPointInsideLoop(boundary, jumpPoint):
		return jumpPoint
	return None
コード例 #8
0
ファイル: comb.py プロジェクト: elmom/Skeinforge-Mirror
def getInsideness( path, loop ):
	"Get portion of the path which is inside the loop."
	if len( path ) < 2:
		return 0.0
	pathLength = euclidean.getPathLength( path )
	incrementRatio = 0.017
	increment = incrementRatio * pathLength
	oldPoint = path[ 0 ]
	numberOfPointsInside = float( euclidean.isPointInsideLoop( loop, oldPoint ) )
	for point in path[ 1 : ]:
		segment = point - oldPoint
		distance = abs( segment )
		numberOfPosts = int( math.ceil( distance / increment ) )
		if numberOfPosts > 0:
			segmentIncrement = segment / float( numberOfPosts )
			for post in xrange( numberOfPosts ):
				postPoint = oldPoint + float( post ) * segmentIncrement
				numberOfPointsInside += float( euclidean.isPointInsideLoop( loop, postPoint ) )
			oldPoint = point
	return incrementRatio * numberOfPointsInside
コード例 #9
0
ファイル: comb.py プロジェクト: GottfriedSp/ReplicatorG
 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
コード例 #10
0
def getInsideness(path, loop):
    "Get portion of the path which is inside the loop."
    if len(path) < 2:
        return 0.0
    pathLength = euclidean.getPathLength(path)
    incrementRatio = 0.017
    increment = incrementRatio * pathLength
    oldPoint = path[0]
    numberOfPointsInside = float(euclidean.isPointInsideLoop(loop, oldPoint))
    for point in path[1:]:
        segment = point - oldPoint
        distance = abs(segment)
        numberOfPosts = int(math.ceil(distance / increment))
        if numberOfPosts > 0:
            segmentIncrement = segment / float(numberOfPosts)
            for post in xrange(numberOfPosts):
                postPoint = oldPoint + float(post) * segmentIncrement
                numberOfPointsInside += float(
                    euclidean.isPointInsideLoop(loop, postPoint))
            oldPoint = point
    return incrementRatio * numberOfPointsInside
コード例 #11
0
 def __init__(self, begin, loop, runningJumpSpace, segment):
     'Initialize'
     self.distance = 0.0
     self.point = begin
     steps = 10
     spaceOverSteps = runningJumpSpace / float(steps)
     for numerator in xrange(1, steps + 1):
         distance = float(numerator) * spaceOverSteps
         point = begin + segment * distance
         if euclidean.isPointInsideLoop(loop, point):
             self.distance = distance
             self.point = point
         else:
             return
コード例 #12
0
def getInsetLoopsFromLoop(loop, radius, thresholdRatio=0.9):
	'Get the inset loops, which might overlap.'
	isInset = radius > 0
	insetLoops = []
	isLoopWiddershins = euclidean.isWiddershins(loop)
	arounds = getAroundsFromLoop(loop, radius, thresholdRatio)
	for around in arounds:
		leftPoint = euclidean.getLeftPoint(around)
		shouldBeWithin = (isInset == isLoopWiddershins)
		if euclidean.isPointInsideLoop(loop, leftPoint) == shouldBeWithin:
			if isLoopWiddershins != euclidean.isWiddershins(around):
				around.reverse()
			insetLoops.append(around)
	return insetLoops
コード例 #13
0
ファイル: comb.py プロジェクト: folksjos/RepG
def getJumpPointIfInside(boundary, otherPoint, edgeWidth, runningJumpSpace):
    'Get the jump point if it is inside the boundary, otherwise return None.'
    insetBoundary = intercircle.getSimplifiedInsetFromClockwiseLoop(
        boundary, -edgeWidth)
    closestJumpDistanceIndex = euclidean.getClosestDistanceIndexToLine(
        otherPoint, insetBoundary)
    jumpIndex = (closestJumpDistanceIndex.index + 1) % len(insetBoundary)
    jumpPoint = euclidean.getClosestPointOnSegment(
        insetBoundary[closestJumpDistanceIndex.index],
        insetBoundary[jumpIndex], otherPoint)
    jumpPoint = getJumpPoint(jumpPoint, otherPoint, boundary, runningJumpSpace)
    if euclidean.isPointInsideLoop(boundary, jumpPoint):
        return jumpPoint
    return None
コード例 #14
0
def getInsetLoopsFromLoop(inset, loop, thresholdRatio=0.9):
    "Get the inset loops, which might overlap."
    isInset = inset > 0
    insetLoops = []
    isLoopWiddershins = euclidean.isWiddershins(loop)
    arounds = getAroundsFromLoop(loop, inset, thresholdRatio)
    for around in arounds:
        leftPoint = euclidean.getLeftPoint(around)
        shouldBeWithin = (isInset == isLoopWiddershins)
        if euclidean.isPointInsideLoop(loop, leftPoint) == shouldBeWithin:
            if isLoopWiddershins != euclidean.isWiddershins(around):
                around.reverse()
            insetLoops.append(around)
    return insetLoops
コード例 #15
0
ファイル: comb.py プロジェクト: GottfriedSp/ReplicatorG
 def __init__(self, begin, loop, runningJumpSpace, segment):
     "Initialize"
     self.distance = 0.0
     self.point = begin
     steps = 10
     spaceOverSteps = runningJumpSpace / float(steps)
     for numerator in xrange(1, steps + 1):
         distance = float(numerator) * spaceOverSteps
         point = begin + segment * distance
         if euclidean.isPointInsideLoop(loop, point):
             self.distance = distance
             self.point = point
         else:
             return
コード例 #16
0
ファイル: comb.py プロジェクト: elmom/Skeinforge-Mirror
	def getPathBetween( self, loop, points ):
		"Add a path between the perimeter and the fill."
		paths = getPathsByIntersectedLoop( points[ 1 ], points[ 2 ], loop )
		shortestPath = paths[ int( euclidean.getPathLength( paths[ 1 ] ) < euclidean.getPathLength( paths[ 0 ] ) ) ]
		if not euclidean.isWiddershins( shortestPath ):
			shortestPath.reverse()
		loopAround = intercircle.getLargestInsetLoopFromLoopNoMatterWhat( shortestPath, - self.combInset )
		endMinusBegin = points[ 3 ] - points[ 0 ]
		endMinusBegin = 1.3 * self.combInset * euclidean.getNormalized( endMinusBegin )
		aroundPaths = getPathsByIntersectedLoop( points[ 0 ] - endMinusBegin, points[ 3 ] + endMinusBegin, loopAround )
		insidePath = aroundPaths[ int( getInsideness( aroundPaths[ 1 ], loop ) > getInsideness( aroundPaths[ 0 ], loop ) ) ]
		pathBetween = []
		for point in insidePath:
			if euclidean.isPointInsideLoop( loop, point ):
				pathBetween.append(point )
		return pathBetween
コード例 #17
0
 def getPathBetween(self, loop, points):
     "Add a path between the perimeter and the fill."
     paths = getPathsByIntersectedLoop(points[1], points[2], loop)
     shortestPath = paths[int(
         euclidean.getPathLength(paths[1]) < euclidean.getPathLength(
             paths[0]))]
     if not euclidean.isWiddershins(shortestPath):
         shortestPath.reverse()
     loopAround = intercircle.getLargestInsetLoopFromLoopNoMatterWhat(
         shortestPath, -self.combInset)
     endMinusBegin = points[3] - points[0]
     endMinusBegin = 1.3 * self.combInset * euclidean.getNormalized(
         endMinusBegin)
     aroundPaths = getPathsByIntersectedLoop(points[0] - endMinusBegin,
                                             points[3] + endMinusBegin,
                                             loopAround)
     insidePath = aroundPaths[int(
         getInsideness(aroundPaths[1], loop) > getInsideness(
             aroundPaths[0], loop))]
     pathBetween = []
     for point in insidePath:
         if euclidean.isPointInsideLoop(loop, point):
             pathBetween.append(point)
     return pathBetween
コード例 #18
0
def getIsPointInsideALoop(loops, point):
    "Determine if a point is inside a loop of a loop list."
    for loop in loops:
        if euclidean.isPointInsideLoop(loop, point):
            return True
    return False
コード例 #19
0
ファイル: widen.py プロジェクト: Spacexula/SFACT
def getIsPointInsideALoop(loops, point):
	'Determine if a point is inside a loop of a loop list.'
	for loop in loops:
		if euclidean.isPointInsideLoop(loop, point):
			return True
	return False