Example #1
0
def getInclusiveLoops( allPoints, corners, importRadius, isInteriorWanted = True ):
	"Get loops which include most of the points."
	circleNodes = intercircle.getCircleNodesFromPoints( allPoints, importRadius )
	centers = intercircle.getCentersFromCircleNodes( circleNodes )
	clockwiseLoops = []
	inclusiveLoops = []
	tinyRadius = 0.03 * importRadius
	for loop in centers:
		if len( loop ) > 2:
			insetPoint = getInsetPoint( loop, tinyRadius )
			if getNumberOfOddIntersectionsFromLoops( insetPoint, centers ) % 4 == 0:
				inclusiveLoops.append( loop )
			else:
				clockwiseLoops.append( loop )
	pointTable = {}
	for inclusiveLoop in inclusiveLoops:
		addLoopToPointTable( inclusiveLoop, pointTable )
	if not isInteriorWanted:
		return getLoopsWithCorners( corners, importRadius, inclusiveLoops, pointTable )
	clockwiseLoops = getLoopsInOrderOfArea( compareAreaDescending, clockwiseLoops )
	for clockwiseLoop in clockwiseLoops:
			if getOverlapRatio( clockwiseLoop, pointTable ) < 0.1:
				inclusiveLoops.append( clockwiseLoop )
				addLoopToPointTable( clockwiseLoop, pointTable )
	return getLoopsWithCorners( corners, importRadius, inclusiveLoops, pointTable )
Example #2
0
	def addPathBeforeEnd( self, aroundBetweenPath, location, loop ):
		"Add the path before the end of the loop."
		halfFillInset = 0.5 * self.fillInset
		if self.arrivalInsetFollowDistance < halfFillInset:
			return
		locationComplex = location.dropAxis( 2 )
		closestInset = None
		closestDistanceIndex = euclidean.DistanceIndex( 999999999999999999.0, - 1 )
		loop = euclidean.getAwayPoints( loop, self.extrusionWidth )
		circleNodes = intercircle.getCircleNodesFromLoop( loop, self.fillInset )
		centers = []
		centers = intercircle.getCentersFromCircleNodes( circleNodes )
		for center in centers:
			inset = intercircle.getInsetFromClockwiseLoop( center, halfFillInset )
			if euclidean.isLargeSameDirection( inset, center, self.fillInset ):
				if euclidean.isPathInsideLoop( loop, inset ) == euclidean.isWiddershins( loop ):
					distanceIndex = euclidean.getNearestDistanceIndex( locationComplex, inset )
					if distanceIndex.distance < closestDistanceIndex.distance:
						closestInset = inset
						closestDistanceIndex = distanceIndex
		if closestInset == None:
			return
		extrusionHalfWidth = 0.5 * self.extrusionWidth
		closestInset = euclidean.getLoopStartingNearest( extrusionHalfWidth, locationComplex, closestInset )
		if euclidean.getPolygonLength( closestInset ) < 0.2 * self.arrivalInsetFollowDistance:
			return
		closestInset.append( closestInset[ 0 ] )
		closestInset = euclidean.getSimplifiedPath( closestInset, self.extrusionWidth )
		closestInset.reverse()
		pathBeforeArrival = euclidean.getClippedAtEndLoopPath( self.arrivalInsetFollowDistance, closestInset )
		pointBeforeArrival = pathBeforeArrival[ - 1 ]
		aroundBetweenPath.append( pointBeforeArrival )
		if self.arrivalInsetFollowDistance <= halfFillInset:
			return
		aroundBetweenPath += euclidean.getClippedAtEndLoopPath( halfFillInset, closestInset )[ len( pathBeforeArrival ) - 1 : ]
Example #3
0
def addAlreadyFilledArounds( alreadyFilledArounds, loop, radius ):
	"Add already filled loops around loop to alreadyFilledArounds."
	radius = abs( radius )
	alreadyFilledLoop = []
	slightlyGreaterThanRadius = 1.01 * radius
	muchGreaterThanRadius = 2.5 * radius
	circleNodes = intercircle.getCircleNodesFromLoop( loop, slightlyGreaterThanRadius )
	centers = intercircle.getCentersFromCircleNodes( circleNodes )
	for center in centers:
		alreadyFilledInset = intercircle.getSimplifiedInsetFromClockwiseLoop( center, radius )
		if euclidean.isLarge( alreadyFilledInset, muchGreaterThanRadius ) or euclidean.isWiddershins( alreadyFilledInset ):
			alreadyFilledLoop.append( alreadyFilledInset )
	if len( alreadyFilledLoop ) > 0:
		alreadyFilledArounds.append( alreadyFilledLoop )
def getBridgeLoops( layerThickness, loop ):
	"Get the inset bridge loops from the loop."
	halfWidth = 1.5 * layerThickness
	slightlyGreaterThanHalfWidth = 1.1 * halfWidth
	muchGreaterThanHalfWIdth = 2.5 * halfWidth
	extrudateLoops = []
	circleNodes = intercircle.getCircleNodesFromLoop( loop, slightlyGreaterThanHalfWidth )
	centers = intercircle.getCentersFromCircleNodes( circleNodes )
	for center in centers:
		extrudateLoop = intercircle.getSimplifiedInsetFromClockwiseLoop( center, halfWidth )
		if euclidean.isLargeSameDirection( extrudateLoop, center, muchGreaterThanHalfWIdth ):
			if euclidean.isPathInsideLoop( loop, extrudateLoop ) == euclidean.isWiddershins( loop ):
				extrudateLoop.reverse()
				extrudateLoops.append( extrudateLoop )
	return extrudateLoops
Example #5
0
def addAlreadyFilledArounds(alreadyFilledArounds, loop, radius):
    "Add already filled loops around loop to alreadyFilledArounds."
    radius = abs(radius)
    alreadyFilledLoop = []
    slightlyGreaterThanRadius = 1.01 * radius
    muchGreaterThanRadius = 2.5 * radius
    circleNodes = intercircle.getCircleNodesFromLoop(
        loop, slightlyGreaterThanRadius)
    centers = intercircle.getCentersFromCircleNodes(circleNodes)
    for center in centers:
        alreadyFilledInset = intercircle.getSimplifiedInsetFromClockwiseLoop(
            center, radius)
        if euclidean.isLarge(alreadyFilledInset, muchGreaterThanRadius
                             ) or euclidean.isWiddershins(alreadyFilledInset):
            alreadyFilledLoop.append(alreadyFilledInset)
    if len(alreadyFilledLoop) > 0:
        alreadyFilledArounds.append(alreadyFilledLoop)
def getInclusiveLoops( allPoints, corners, importRadius, isInteriorWanted ):
	"Get loops which include most of the points."
	circleNodes = intercircle.getCircleNodesFromPoints( allPoints, importRadius )
	centers = intercircle.getCentersFromCircleNodes( circleNodes )
	loops = intercircle.getLoopsFromLoopsDirection( True, centers )
	pointTable = {}
	for loop in loops:
		addLoopToPointTable( loop, pointTable )
	if not isInteriorWanted:
		return getLoopsWithCorners( corners, importRadius, loops, pointTable )
	clockwiseLoops = getLoopsInDescendingOrderOfArea( intercircle.getLoopsFromLoopsDirection( False, centers ) )
	clockwiseLoops.reverse()
	for clockwiseLoop in clockwiseLoops:
		if len( clockwiseLoop ) > 2 and euclidean.getMaximumSpan( clockwiseLoop ) > 2.5 * importRadius:
			if getOverlapRatio( clockwiseLoop, pointTable ) < 0.45:
				loops.append( clockwiseLoop )
				addLoopToPointTable( clockwiseLoop, pointTable )
	return getLoopsWithCorners( corners, importRadius, loops, pointTable )
Example #7
0
	def getBetweens( self ):
		"Set betweens for the layer."
		if self.layerZ in self.betweenTable:
			return self.betweenTable[ self.layerZ ]
		if self.layerZ not in self.layerTable:
			return []
		halfFillInset = 0.5 * self.fillInset
		betweens = []
		for boundaryLoop in self.layerTable[ self.layerZ ]:
			circleNodes = intercircle.getCircleNodesFromLoop( boundaryLoop, self.fillInset )
			centers = intercircle.getCentersFromCircleNodes( circleNodes )
			for center in centers:
				inset = intercircle.getSimplifiedInsetFromClockwiseLoop( center, halfFillInset )
				if euclidean.isLargeSameDirection( inset, center, self.fillInset ):
					if euclidean.isPathInsideLoop( boundaryLoop, inset ) == euclidean.isWiddershins( boundaryLoop ):
						betweens.append( inset )
		self.betweenTable[ self.layerZ ] = betweens
		return betweens
Example #8
0
 def addPathBeforeEnd(self, aroundBetweenPath, location, loop):
     "Add the path before the end of the loop."
     halfFillInset = 0.5 * self.fillInset
     if self.arrivalInsetFollowDistance < halfFillInset:
         return
     locationComplex = location.dropAxis(2)
     closestInset = None
     closestDistanceIndex = euclidean.DistanceIndex(999999999999999999.0,
                                                    -1)
     loop = euclidean.getAwayPoints(loop, self.extrusionWidth)
     circleNodes = intercircle.getCircleNodesFromLoop(loop, self.fillInset)
     centers = []
     centers = intercircle.getCentersFromCircleNodes(circleNodes)
     for center in centers:
         inset = intercircle.getInsetFromClockwiseLoop(
             center, halfFillInset)
         if euclidean.isLargeSameDirection(inset, center, self.fillInset):
             if euclidean.isPathInsideLoop(
                     loop, inset) == euclidean.isWiddershins(loop):
                 distanceIndex = euclidean.getNearestDistanceIndex(
                     locationComplex, inset)
                 if distanceIndex.distance < closestDistanceIndex.distance:
                     closestInset = inset
                     closestDistanceIndex = distanceIndex
     if closestInset == None:
         return
     extrusionHalfWidth = 0.5 * self.extrusionWidth
     closestInset = euclidean.getLoopStartingNearest(
         extrusionHalfWidth, locationComplex, closestInset)
     if euclidean.getPolygonLength(
             closestInset) < 0.2 * self.arrivalInsetFollowDistance:
         return
     closestInset.append(closestInset[0])
     closestInset = euclidean.getSimplifiedPath(closestInset,
                                                self.extrusionWidth)
     closestInset.reverse()
     pathBeforeArrival = euclidean.getClippedAtEndLoopPath(
         self.arrivalInsetFollowDistance, closestInset)
     pointBeforeArrival = pathBeforeArrival[-1]
     aroundBetweenPath.append(pointBeforeArrival)
     if self.arrivalInsetFollowDistance <= halfFillInset:
         return
     aroundBetweenPath += euclidean.getClippedAtEndLoopPath(
         halfFillInset, closestInset)[len(pathBeforeArrival) - 1:]
Example #9
0
 def getBetweens(self):
     "Set betweens for the layer."
     if self.layerZ in self.betweenTable:
         return self.betweenTable[self.layerZ]
     if self.layerZ not in self.layerTable:
         return []
     halfFillInset = 0.5 * self.fillInset
     betweens = []
     for boundaryLoop in self.layerTable[self.layerZ]:
         circleNodes = intercircle.getCircleNodesFromLoop(
             boundaryLoop, self.fillInset)
         centers = intercircle.getCentersFromCircleNodes(circleNodes)
         for center in centers:
             inset = intercircle.getSimplifiedInsetFromClockwiseLoop(
                 center, halfFillInset)
             if euclidean.isLargeSameDirection(inset, center,
                                               self.fillInset):
                 if euclidean.isPathInsideLoop(
                         boundaryLoop,
                         inset) == euclidean.isWiddershins(boundaryLoop):
                     betweens.append(inset)
     self.betweenTable[self.layerZ] = betweens
     return betweens