Exemplo n.º 1
0
 def addWiden(self, rotatedBoundaryLayer):
     "Add widen to the layer."
     loops = triangle_mesh.getLoopsInOrderOfArea(
         triangle_mesh.compareAreaAscending, rotatedBoundaryLayer.loops)
     widdershinsLoops = []
     clockwiseInsetLoops = []
     for loopIndex in xrange(len(loops)):
         loop = loops[loopIndex]
         if euclidean.isWiddershins(loop):
             otherLoops = loops[:loopIndex] + loops[loopIndex + 1:]
             leftPoint = euclidean.getLeftPoint(loop)
             if euclidean.isPointInsideLoops(otherLoops, leftPoint):
                 self.distanceFeedRate.addGcodeFromLoop(
                     loop, rotatedBoundaryLayer.z)
             else:
                 widdershinsLoops.append(loop)
         else:
             clockwiseInsetLoops += intercircle.getInsetLoopsFromLoop(
                 self.doublePerimeterWidth, loop)
             self.distanceFeedRate.addGcodeFromLoop(loop,
                                                    rotatedBoundaryLayer.z)
     for widdershinsLoop in widdershinsLoops:
         outsetLoop = intercircle.getLargestInsetLoopFromLoop(
             widdershinsLoop, -self.doublePerimeterWidth)
         widenedLoop = getWidenedLoop(widdershinsLoop, clockwiseInsetLoops,
                                      outsetLoop, self.perimeterWidth,
                                      self.tinyRadius)
         self.distanceFeedRate.addGcodeFromLoop(widenedLoop,
                                                rotatedBoundaryLayer.z)
Exemplo n.º 2
0
def getIsIntersectingWithinList( loop, loopList ):
	"Determine if the loop is intersecting or is within the loop list."
	leftPoint = euclidean.getLeftPoint( loop )
	for otherLoop in loopList:
		if euclidean.getNumberOfIntersectionsToLeft( otherLoop, leftPoint ) % 2 == 1:
			return True
	return euclidean.isLoopIntersectingLoops( loop, loopList )
Exemplo n.º 3
0
def isIntersectingWithinList( loop, loopList ):
	"Determine if the loop is intersecting or is within the loop list."
	if euclidean.isLoopIntersectingLoops( loop, loopList ):
		return True
	totalNumberOfIntersections = 0
	for otherLoop in loopList:
		leftPoint = euclidean.getLeftPoint( otherLoop )
		totalNumberOfIntersections += euclidean.getNumberOfIntersectionsToLeft( leftPoint, loop )
	return totalNumberOfIntersections % 2 == 1
Exemplo n.º 4
0
def isIntersectingWithinList(loop, loopList):
    "Determine if the loop is intersecting or is within the loop list."
    if euclidean.isLoopIntersectingLoops(loop, loopList):
        return True
    totalNumberOfIntersections = 0
    for otherLoop in loopList:
        leftPoint = euclidean.getLeftPoint(otherLoop)
        totalNumberOfIntersections += euclidean.getNumberOfIntersectionsToLeft(
            leftPoint, loop)
    return totalNumberOfIntersections % 2 == 1
Exemplo n.º 5
0
def getInsetSeparateLoopsFromLoops( inset, loops ):
	"Get the separate inset loops."
	isInset = inset > 0
	insetSeparateLoops = []
	radius = abs( inset )
	arounds = getAroundsFromLoops( loops, radius )
	for around in arounds:
		leftPoint = euclidean.getLeftPoint( around )
		if isInset == euclidean.isInFilledRegion( loops, leftPoint ):
			around.reverse()
			insetSeparateLoops.append( around )
	return insetSeparateLoops
Exemplo n.º 6
0
def getInsetSeparateLoopsFromLoops(inset, loops, thresholdRatio=0.9):
    "Get the separate inset loops."
    isInset = inset > 0
    insetSeparateLoops = []
    radius = abs(inset)
    arounds = getAroundsFromLoops(loops, radius, thresholdRatio)
    for around in arounds:
        leftPoint = euclidean.getLeftPoint(around)
        if isInset == euclidean.isInFilledRegion(loops, leftPoint):
            if isInset:
                around.reverse()
            insetSeparateLoops.append(around)
    return insetSeparateLoops
Exemplo n.º 7
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
Exemplo n.º 8
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
Exemplo n.º 9
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 )
		loops = getLoopsInOrderOfArea( compareAreaDescending, euclidean.getSimplifiedLoops( originalLoops, self.importRadius ) )
		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
Exemplo n.º 10
0
	def addWiden( self, rotatedBoundaryLayer ):
		"Add widen to the layer."
		loops = triangle_mesh.getLoopsInOrderOfArea( triangle_mesh.compareAreaAscending, rotatedBoundaryLayer.loops )
		widdershinsLoops = []
		clockwiseInsetLoops = []
		for loopIndex in xrange( len( loops ) ):
			loop = loops[ loopIndex ]
			if euclidean.isWiddershins( loop ):
				otherLoops = loops[ : loopIndex ] + loops[ loopIndex + 1 : ]
				leftPoint = euclidean.getLeftPoint( loop )
				if euclidean.isPointInsideLoops( otherLoops, leftPoint ):
					self.distanceFeedRate.addGcodeFromLoop( loop, rotatedBoundaryLayer.z )
				else:
					widdershinsLoops.append( loop )
			else:
				clockwiseInsetLoops += intercircle.getInsetLoopsFromLoop( self.doublePerimeterWidth, loop )
				self.distanceFeedRate.addGcodeFromLoop( loop, rotatedBoundaryLayer.z )
		for widdershinsLoop in widdershinsLoops:
			outsetLoop = intercircle.getLargestInsetLoopFromLoop( widdershinsLoop, - self.doublePerimeterWidth )
			widenedLoop = getWidenedLoop( widdershinsLoop, clockwiseInsetLoops, outsetLoop, self.perimeterWidth, self.tinyRadius )
			self.distanceFeedRate.addGcodeFromLoop( widenedLoop, rotatedBoundaryLayer.z )
Exemplo n.º 11
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