コード例 #1
0
def getWidenedLoop(loop, loopList, outsetLoop, radius, tinyRadius):
    "Get the widened loop."
    intersectingWithinLoops = getIntersectingWithinLoops(
        loop, loopList, outsetLoop)
    if len(intersectingWithinLoops) < 1:
        return loop
    widdershinsLoops = [loop]
    for intersectingWithinLoop in intersectingWithinLoops:
        reversedLoop = intersectingWithinLoop[:]
        reversedLoop.reverse()
        widdershinsLoops.append(reversedLoop)
    paths = []
    for widdershinsLoopIndex in xrange(len(widdershinsLoops)):
        widdershinsLoop = widdershinsLoops[widdershinsLoopIndex]
        for pointIndex in xrange(len(widdershinsLoop)):
            pointBegin = widdershinsLoop[pointIndex]
            pointEnd = widdershinsLoop[(pointIndex + 1) % len(widdershinsLoop)]
            otherLoops = widdershinsLoops[:
                                          widdershinsLoopIndex] + widdershinsLoops[
                                              widdershinsLoopIndex + 1:]
            segments = getSegmentsFromPoints(otherLoops, pointBegin, pointEnd)
            for segment in segments:
                addToPaths(paths, tinyRadius, segment)
    for endIndex in xrange(len(paths) - 1, 0, -1):
        connectEndPath(endIndex, paths, tinyRadius)
    widenedLoop = []
    for path in paths:
        widenedLoop += path
    if abs(widenedLoop[0] - widenedLoop[-1]) < tinyRadius:
        widenedLoop = widenedLoop[1:]
    return euclidean.getSimplifiedLoop(widenedLoop, radius)
コード例 #2
0
ファイル: widen.py プロジェクト: CNCBASHER/skeinforge
def getWidenedLoop( loop, loopList, outsetLoop, radius, tinyRadius ):
	"Get the widened loop."
	intersectingWithinLoops = getIntersectingWithinLoops( loop, loopList, outsetLoop )
	if len( intersectingWithinLoops ) < 1:
		return loop
	widdershinsLoops = [ loop ]
	for intersectingWithinLoop in intersectingWithinLoops:
		reversedLoop = intersectingWithinLoop[ : ]
		reversedLoop.reverse()
		widdershinsLoops.append( reversedLoop )
	paths = []
	for widdershinsLoopIndex in xrange( len( widdershinsLoops ) ):
		widdershinsLoop = widdershinsLoops[ widdershinsLoopIndex ]
		for pointIndex in xrange( len( widdershinsLoop ) ):
			pointBegin = widdershinsLoop[ pointIndex ]
			pointEnd = widdershinsLoop[ ( pointIndex + 1 ) % len( widdershinsLoop ) ]
			otherLoops = widdershinsLoops[ : widdershinsLoopIndex ] + widdershinsLoops[ widdershinsLoopIndex + 1 : ]
			segments = getSegmentsFromPoints( otherLoops, pointBegin, pointEnd )
			for segment in segments:
				addToPaths( paths, tinyRadius, segment )
	for endIndex in xrange( len( paths ) - 1, 0, - 1 ):
		connectEndPath( endIndex, paths, tinyRadius )
	widenedLoop = []
	for path in paths:
		widenedLoop += path
	if abs( widenedLoop[ 0 ] - widenedLoop[ - 1 ] ) < tinyRadius:
		widenedLoop = widenedLoop[ 1 : ]
	return euclidean.getSimplifiedLoop( widenedLoop, radius )
コード例 #3
0
	def getLoopsFromMesh( self, z ):
		"Get loops from a carve of a mesh."
		originalLoops = []
		if self.isCorrectMesh:
			originalLoops = getLoopsFromCorrectMesh( self.edges, self.faces, self.vertices, z )
		if len( originalLoops ) < 1:
			originalLoops = getLoopsFromUnprovenMesh( self.edges, self.faces, self.importRadius, self.vertices, z )
		simplifiedLoops = []
		for originalLoop in originalLoops:
			simplifiedLoops.append( euclidean.getSimplifiedLoop( originalLoop, self.importRadius ) )
		loops = getLoopsInOrderOfArea( compareAreaDescending, simplifiedLoops )
		for loopIndex in xrange( len( loops ) ):
			loop = loops[ loopIndex ]
			leftPoint = euclidean.getLeftPoint( loop )
			isInFilledRegion = euclidean.isInFilledRegion( loops[ : loopIndex ] + loops[ loopIndex + 1 : ], leftPoint )
			if isInFilledRegion == euclidean.isWiddershins( loop ):
				loop.reverse()
		return loops
コード例 #4
0
	def getLoopsFromMesh( self, z ):
		"Get loops from a carve of a mesh."
		originalLoops = []
		if self.isCorrectMesh:
			originalLoops = getLoopsFromCorrectMesh( self.edges, self.faces, self.vertices, z )
		if len( originalLoops ) < 1:
			originalLoops = getLoopsFromUnprovenMesh( self.edges, self.faces, self.importRadius, self.vertices, z )
		simplifiedLoops = []
		for originalLoop in originalLoops:
			simplifiedLoops.append( euclidean.getSimplifiedLoop( originalLoop, self.importRadius ) )
		loops = getLoopsInDescendingOrderOfArea( simplifiedLoops )
		for loopIndex in xrange( len( loops ) ):
			loop = loops[ loopIndex ]
			leftPoint = euclidean.getLeftPoint( loop )
			totalNumberOfIntersectionsToLeft = 0
			for otherLoop in loops[ : loopIndex ] + loops[ loopIndex + 1 : ]:
				totalNumberOfIntersectionsToLeft += euclidean.getNumberOfIntersectionsToLeft( leftPoint, otherLoop )
			loopIsWiddershins = euclidean.isWiddershins( loop )
			isEven = totalNumberOfIntersectionsToLeft % 2 == 0
			if isEven != loopIsWiddershins:
				loop.reverse()
		return loops
コード例 #5
0
def getSimplifiedInsetFromClockwiseLoop( loop, radius ):
	"Get loop inset from clockwise loop, out from widdershins loop."
	return getWithoutIntersections( euclidean.getSimplifiedLoop( getInsetFromClockwiseLoop( loop, radius ), radius ) )
コード例 #6
0
def getSimplifiedInsetFromClockwiseLoop( loop, radius ):
	"Get loop inset from clockwise loop, out from widdershins loop."
	return getWithoutIntersections( euclidean.getSimplifiedLoop( getInsetFromClockwiseLoop( loop, radius ), radius ) )