示例#1
0
 def splitPointGetAfter(self, location, nextActive, oldActiveLocation):
     "Fillet a point into arc segments and return the end of the last segment."
     afterSegment = nextActive.minus(location)
     afterSegmentLength = afterSegment.length()
     afterSegmentExtension = 0.5 * afterSegmentLength
     if afterSegmentExtension == 0.0:
         self.shouldAddLine = True
         return location
     beforeSegment = oldActiveLocation.minus(location)
     beforeSegmentLength = beforeSegment.length()
     if beforeSegmentLength == 0.0:
         self.shouldAddLine = True
         return location
     radius = self.layerHalfExtrusionWidth
     afterSegmentNormalized = afterSegment.times(1.0 / afterSegmentLength)
     beforeSegmentNormalized = beforeSegment.times(1.0 /
                                                   beforeSegmentLength)
     betweenCenterDotNormalized = afterSegmentNormalized.plus(
         beforeSegmentNormalized)
     if betweenCenterDotNormalized.length(
     ) < 0.01 * self.layerHalfExtrusionWidth:
         self.shouldAddLine = True
         return location
     betweenCenterDotNormalized.normalize()
     beforeSegmentNormalizedWiddershins = euclidean.getRotatedWiddershinsQuarterAroundZAxis(
         beforeSegmentNormalized)
     betweenAfterPlaneDot = abs(
         euclidean.getPlaneDot(betweenCenterDotNormalized,
                               beforeSegmentNormalizedWiddershins))
     centerDotDistance = radius / betweenAfterPlaneDot
     bevelLength = math.sqrt(centerDotDistance * centerDotDistance -
                             radius * radius)
     radiusOverBevelLength = radius / bevelLength
     bevelLength = min(bevelLength, radius)
     bevelLength = min(afterSegmentExtension, bevelLength)
     beforePoint = oldActiveLocation
     if beforeSegmentLength < bevelLength:
         bevelLength = beforeSegmentLength
     else:
         beforePoint = euclidean.getPointPlusSegmentWithLength(
             bevelLength, location, beforeSegment)
         self.addLinearMovePoint(beforePoint)
     afterPoint = euclidean.getPointPlusSegmentWithLength(
         bevelLength, location, afterSegment)
     radius = bevelLength * radiusOverBevelLength
     centerDotDistance = radius / betweenAfterPlaneDot
     center = location.plus(
         betweenCenterDotNormalized.times(centerDotDistance))
     afterCenterSegment = afterPoint.minus(center)
     beforeCenterSegment = beforePoint.minus(center)
     afterCenterDifferenceAngle = euclidean.getAngleAroundZAxisDifference(
         afterCenterSegment, beforeCenterSegment)
     self.addArc(afterCenterDifferenceAngle, afterPoint,
                 beforeCenterSegment, beforePoint, center)
     return afterPoint
示例#2
0
	def splitPointGetAfter( self, location, nextActive, oldActiveLocation ):
		"Fillet a point into arc segments and return the end of the last segment."
		afterSegment = nextActive.minus( location )
		afterSegmentLength = afterSegment.length()
		afterSegmentExtension = 0.5 * afterSegmentLength
		if afterSegmentExtension == 0.0:
			self.shouldAddLine = True
			return location
		beforeSegment = oldActiveLocation.minus( location )
		beforeSegmentLength = beforeSegment.length()
		if beforeSegmentLength == 0.0:
			self.shouldAddLine = True
			return location
		radius = self.layerHalfExtrusionWidth
		afterSegmentNormalized = afterSegment.times( 1.0 / afterSegmentLength )
		beforeSegmentNormalized = beforeSegment.times( 1.0 / beforeSegmentLength )
		betweenCenterDotNormalized = afterSegmentNormalized.plus( beforeSegmentNormalized )
		if betweenCenterDotNormalized.length() < 0.01 * self.layerHalfExtrusionWidth:
			self.shouldAddLine = True
			return location
		betweenCenterDotNormalized.normalize()
		beforeSegmentNormalizedWiddershins = euclidean.getRotatedWiddershinsQuarterAroundZAxis( beforeSegmentNormalized )
		betweenAfterPlaneDot = abs( euclidean.getPlaneDot( betweenCenterDotNormalized, beforeSegmentNormalizedWiddershins ) )
		centerDotDistance = radius / betweenAfterPlaneDot
		bevelLength = math.sqrt( centerDotDistance * centerDotDistance - radius * radius )
		radiusOverBevelLength = radius / bevelLength
		bevelLength = min( bevelLength, radius )
		bevelLength = min( afterSegmentExtension, bevelLength )
		beforePoint = oldActiveLocation
		if beforeSegmentLength < bevelLength:
			bevelLength = beforeSegmentLength
		else:
			beforePoint = euclidean.getPointPlusSegmentWithLength( bevelLength, location, beforeSegment )
			self.addLinearMovePoint( beforePoint )
		afterPoint = euclidean.getPointPlusSegmentWithLength( bevelLength, location, afterSegment )
		radius = bevelLength * radiusOverBevelLength
		centerDotDistance = radius / betweenAfterPlaneDot
		center = location.plus( betweenCenterDotNormalized.times( centerDotDistance ) )
		afterCenterSegment = afterPoint.minus( center )
		beforeCenterSegment = beforePoint.minus( center )
		afterCenterDifferenceAngle = euclidean.getAngleAroundZAxisDifference( afterCenterSegment, beforeCenterSegment )
		self.addArc( afterCenterDifferenceAngle, afterPoint, beforeCenterSegment, beforePoint, center )
		return afterPoint
示例#3
0
	def splitPointGetAfter( self, location, nextActive, oldActiveLocation ):
		"Bevel a point and return the end of the bevel."
		bevelLength = 0.5 * self.layerHalfExtrusionWidth
		beforeSegment = oldActiveLocation.minus( location )
		beforeSegmentLength = beforeSegment.length()
		if beforeSegmentLength == 0.0:
			self.shouldAddLine = True
			return location
		afterSegment = nextActive.minus( location )
		afterSegmentExtension = 0.5 * afterSegment.length()
		if afterSegmentExtension == 0.0:
			self.shouldAddLine = True
			return location
		bevelLength = min( afterSegmentExtension, bevelLength )
		if beforeSegmentLength < bevelLength:
			bevelLength = beforeSegmentLength
		else:
			beforePoint = euclidean.getPointPlusSegmentWithLength( bevelLength, location, beforeSegment )
			self.addLinearMovePoint( beforePoint )
		afterPoint = euclidean.getPointPlusSegmentWithLength( bevelLength, location, afterSegment )
		self.addLinearMovePoint( afterPoint )
		return afterPoint
示例#4
0
 def splitPointGetAfter(self, location, nextActive, oldActiveLocation):
     "Bevel a point and return the end of the bevel."
     bevelLength = 0.5 * self.layerHalfExtrusionWidth
     beforeSegment = oldActiveLocation.minus(location)
     beforeSegmentLength = beforeSegment.length()
     if beforeSegmentLength == 0.0:
         self.shouldAddLine = True
         return location
     afterSegment = nextActive.minus(location)
     afterSegmentExtension = 0.5 * afterSegment.length()
     if afterSegmentExtension == 0.0:
         self.shouldAddLine = True
         return location
     bevelLength = min(afterSegmentExtension, bevelLength)
     if beforeSegmentLength < bevelLength:
         bevelLength = beforeSegmentLength
     else:
         beforePoint = euclidean.getPointPlusSegmentWithLength(
             bevelLength, location, beforeSegment)
         self.addLinearMovePoint(beforePoint)
     afterPoint = euclidean.getPointPlusSegmentWithLength(
         bevelLength, location, afterSegment)
     self.addLinearMovePoint(afterPoint)
     return afterPoint