public static PathPattern GetOpeningPattern(float currentSlope, float slope, float length, float radius) {
			ContourPatternStepPair curveOut = GetDivergentCurve(currentSlope, slope, -slope, radius, radius, true);
			ContourPatternStepPair curveOutStraighten = GetDivergentCurve(currentSlope, 0, 0, radius, radius, true);
			ContourPatternStepPair straight = GetStraight(currentSlope, 0, length, length, true);
			ContourPatternStepPair curveIn = GetDivergentCurve(currentSlope, -slope, slope, radius, radius, true);
			ContourPatternStepPair curveInStraighten = GetDivergentCurve(currentSlope, 0, 0, radius, radius, true);
			PathPattern pattern = new PathPattern(curveOut, curveOutStraighten, straight, curveIn, curveInStraighten);
			return pattern;
		}
		public static PathPattern GetBumpPattern(float currentSlope, float bumpSlope, float upLength, float topLength, float downLength, float minRadius, float maxRadius) {
			ContourPatternStepPair turn1 = GetParallelCurve(currentSlope, bumpSlope, minRadius, maxRadius, true);
			ContourPatternStepPair up = GetStraight(currentSlope, bumpSlope, upLength, upLength, true);
			ContourPatternStepPair turn2 = GetParallelCurve(currentSlope, -bumpSlope, maxRadius, minRadius, true);
			ContourPatternStepPair down = GetStraight(currentSlope, -bumpSlope, downLength, downLength, true);
			ContourPatternStepPair turn3 = GetParallelCurve(currentSlope, 0, minRadius, maxRadius, true);
			PathPattern bumpPattern = new PathPattern(turn1, up, turn2, down, turn3);
			return bumpPattern;
		}
		public static PathPattern GetEndPattern(float currentSlope, float topLength, float bottomLength, float endSlope, float radius) {
			ContourPatternStepPair straight = GetStraight(currentSlope, 0, topLength, bottomLength, true);
			ContourPatternStepPair curve = GetDivergentCurve(currentSlope, endSlope, -endSlope, radius, radius, true);
			PathPattern endPattern = new PathPattern(straight, curve);
			return endPattern;
		}
		public static PathPattern GetFlatPattern(float length) {
			ContourPatternStepPair flat = GetStraight(0, 0, length, length, true);
			PathPattern flatPattern = new PathPattern(flat);
			return flatPattern;
		}
		public static PathPattern GetNarrowPattern(float currentSlope, float narrowSlope, float radius) {
			ContourPatternStepPair curveOut = GetDivergentCurve(currentSlope, -narrowSlope, narrowSlope, radius, radius, true);
			ContourPatternStepPair curveBack = GetDivergentCurve(currentSlope, 0, 0, radius, radius, true);
			PathPattern narrowPattern = new PathPattern(curveOut, curveBack);
			return narrowPattern;
		}
		public static PathPattern GetWidenPattern(float currentSlope, float widenSlope, float radius) {
			ContourPatternStepPair curveOut = GetDivergentCurve(currentSlope, widenSlope, -widenSlope, radius, radius, true);
			ContourPatternStepPair curveBack = GetDivergentCurve(currentSlope, 0, 0, radius, radius, true);
			PathPattern widenPattern = new PathPattern(curveOut, curveBack);
			return widenPattern;
		}
		public static PathPattern GetStraightPattern(float currentSlope, float topLength, float bottomLength) {
			ContourPatternStepPair straight = GetStraight(currentSlope, 0, topLength, bottomLength, true);
			PathPattern straightPattern = new PathPattern(straight);
			return straightPattern;
		}
Exemple #8
0
		private void AddPattern(PathPatternType patternType, PathPattern pattern) {
			List<ContourSegment> topSections = new List<ContourSegment>();
			List<ContourSegment> bottomSections = new List<ContourSegment>();

			foreach (ContourPatternStepPair instructionPair in pattern.instructionPairs) {
				if (instructionPair.topInstruction.stepType == ContourPatternStepType.Straight) {
					ContourPatternStepStraight topInstruction = (ContourPatternStepStraight)instructionPair.topInstruction;
					var newSection = topContour.AddStraight(topInstruction.slope, topInstruction.length, topInstruction.bumpify);
					if (newSection) topSections.Add(newSection);
				}
				else if (instructionPair.topInstruction.stepType == ContourPatternStepType.Curve) {
					ContourPatternStepCurve topInstruction = (ContourPatternStepCurve)instructionPair.topInstruction;
					var newSections = topContour.AddCurve(topInstruction.targetSlope, topInstruction.radius, topInstruction.bumpify);
					if (newSections.Count > 0) topSections.AddAll(newSections);
				}

				if (instructionPair.bottomInstruction.stepType == ContourPatternStepType.Straight) {
					ContourPatternStepStraight bottomInstruction = (ContourPatternStepStraight)instructionPair.bottomInstruction;
					var newSection = bottomContour.AddStraight(bottomInstruction.slope, bottomInstruction.length, bottomInstruction.bumpify);
					if (newSection) bottomSections.Add(newSection);
				}
				else if (instructionPair.bottomInstruction.stepType == ContourPatternStepType.Curve) {
					ContourPatternStepCurve bottomInstruction = (ContourPatternStepCurve)instructionPair.bottomInstruction;
					var newSections = bottomContour.AddCurve(bottomInstruction.targetSlope, bottomInstruction.radius, bottomInstruction.bumpify);
					if (newSections.Count > 0) bottomSections.AddAll(newSections);
				}
			}
				
			OnPatternAdded(patternType, topSections, bottomSections);
		}