Ejemplo n.º 1
0
def isPointOrEitherLineBoundarySideInsideLoops( inside, loops, pointBegin, pointCenter, pointEnd, radius ):
	"Determine if the point or a point on either side of the point, is inside the loops."
	if euclidean.isPointInsideLoops( loops, pointCenter ) != inside:
		return False
	segment = pointEnd - pointBegin
	segmentLength = abs( segment )
	if segmentLength <= 0.0:
		return False
	segment /= segmentLength
	addedSegment = radius * complex( segment.imag, - segment.real )
	if euclidean.isPointInsideLoops( loops,  pointCenter + addedSegment ) != inside:
		return False
	return euclidean.isPointInsideLoops( loops,  pointCenter - addedSegment ) == inside
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
def isSegmentInsideAround(aroundLists, segment):
    "Determine if the segment is inside an around."
    midpoint = 0.5 * (segment[0].point + segment[1].point)
    for aroundList in aroundLists:
        if euclidean.isPointInsideLoops(aroundList, midpoint):
            return True
    return False
Ejemplo n.º 4
0
def isSegmentInsideAround( aroundLists, segment ):
	"Determine if the segment is inside an around."
	midpoint = 0.5 * ( segment[ 0 ].point + segment[ 1 ].point )
	for aroundList in aroundLists:
		if euclidean.isPointInsideLoops( aroundList, midpoint ):
			return True
	return False
Ejemplo n.º 5
0
	def getConnectionIsCloseWithoutOverlap( self, location, path ):
		"Determine if the connection is close enough and does not overlap another thread."
		if len( path ) < 1:
			return False
		locationComplex = location.dropAxis( 2 )
		segment = locationComplex - path[ - 1 ]
		segmentLength = abs( segment )
		if segmentLength <= 0.0:
			return True
		segment /= segmentLength
		distance = self.connectingStepLength
		segmentEndLength = segmentLength - self.connectingStepLength
		while distance < segmentEndLength:
			alongPoint = distance * segment + path[ - 1 ]
			if not euclidean.isPointInsideLoops( self.boundaryLoops, alongPoint ):
				return False
			distance += self.connectingStepLength
#		removedLayerPixelTable = self.layerPixelTable.copy()
#		if self.oldLocation in self.maskPixelTableTable:
#			euclidean.removePixelTableFromPixelTable( self.maskPixelTableTable[ self.oldLocation ], removedLayerPixelTable )
#		euclidean.addPathToPixelTable( path[ : - 2 ], removedLayerPixelTable, None, self.layerPixelWidth )
		segmentTable = {}
		euclidean.addSegmentToPixelTable( path[ - 1 ], locationComplex, segmentTable, 2.0, 2.0, self.layerPixelWidth )
#		euclidean.addValueSegmentToPixelTable( path[ - 1 ], locationComplex, segmentTable, None, self.layerPixelWidth )
#		euclidean.addValueSegmentToPixelTable( path[ - 1 ], locationComplex, segmentTable, None, self.layerPixelWidth )
#		maskPixelTable = {}
#		if location in self.maskPixelTableTable:
#			maskPixelTable = self.maskPixelTableTable[ location ]
		if euclidean.isPixelTableIntersecting( self.layerPixelTable, segmentTable, {} ):
#		if euclidean.isPixelTableIntersecting( removedLayerPixelTable, segmentTable, {} ):
			return False
		euclidean.addValueSegmentToPixelTable( path[ - 1 ], locationComplex, self.layerPixelTable, None, self.layerPixelWidth )
#		euclidean.addPixelTableToPixelTable( segmentTable, self.layerPixelTable )
		return True
Ejemplo n.º 6
0
def isPointOrEitherBoundarySideInsideLoops( inside, loops, pointBegin, pointCenter, pointEnd, radius ):
	"Determine if the point or a point on either side of the point, is inside the loops."
	if euclidean.isPointInsideLoops( loops, pointCenter ) != inside:
		return False
	segmentBegin = pointBegin - pointCenter
	segmentEnd = pointEnd - pointCenter
	segmentBeginLength = abs( segmentBegin )
	segmentEndLength = abs( segmentEnd )
	if segmentBeginLength <= 0.0 or segmentEndLength <= 0.0:
		return False
	segmentBegin /= segmentBeginLength
	segmentEnd /= segmentEndLength
	addedSegment = segmentBegin + segmentEnd
	addedSegmentLength = abs( addedSegment )
	if addedSegmentLength > 0.0:
		addedSegment *= radius / addedSegmentLength
	else:
		addedSegment = radius * complex( segmentEnd.imag, - segmentEnd.real )
	if euclidean.isPointInsideLoops( loops,  pointCenter + addedSegment ) != inside:
		return False
	return euclidean.isPointInsideLoops( loops,  pointCenter - addedSegment ) == inside
Ejemplo n.º 7
0
    def getConnectionIsCloseWithoutOverlap(self, location, path):
        "Determine if the connection is close enough and does not overlap another thread."
        if len(path) < 1:
            return False
        locationComplex = location.dropAxis(2)
        segment = locationComplex - path[-1]
        segmentLength = abs(segment)
        if segmentLength <= 0.0:
            return True
        segment /= segmentLength
        distance = self.connectingStepLength
        segmentEndLength = segmentLength - self.connectingStepLength
        while distance < segmentEndLength:
            alongPoint = distance * segment + path[-1]
            if not euclidean.isPointInsideLoops(self.boundaryLoops,
                                                alongPoint):
                return False
            distance += self.connectingStepLength


#		removedLayerPixelTable = self.layerPixelTable.copy()
#		if self.oldLocation in self.maskPixelTableTable:
#			euclidean.removePixelTableFromPixelTable( self.maskPixelTableTable[ self.oldLocation ], removedLayerPixelTable )
#		euclidean.addPathToPixelTable( path[ : - 2 ], removedLayerPixelTable, None, self.layerPixelWidth )
        segmentTable = {}
        euclidean.addSegmentToPixelTable(path[-1], locationComplex,
                                         segmentTable, 2.0, 2.0,
                                         self.layerPixelWidth)
        #		euclidean.addValueSegmentToPixelTable( path[ - 1 ], locationComplex, segmentTable, None, self.layerPixelWidth )
        #		euclidean.addValueSegmentToPixelTable( path[ - 1 ], locationComplex, segmentTable, None, self.layerPixelWidth )
        #		maskPixelTable = {}
        #		if location in self.maskPixelTableTable:
        #			maskPixelTable = self.maskPixelTableTable[ location ]
        if euclidean.isPixelTableIntersecting(self.layerPixelTable,
                                              segmentTable, {}):
            #		if euclidean.isPixelTableIntersecting( removedLayerPixelTable, segmentTable, {} ):
            return False
        euclidean.addValueSegmentToPixelTable(path[-1], locationComplex,
                                              self.layerPixelTable, None,
                                              self.layerPixelWidth)
        #		euclidean.addPixelTableToPixelTable( segmentTable, self.layerPixelTable )
        return True
Ejemplo n.º 8
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 )