private void InsertWheelToothPath(Wheel wheel, WheelTooth tooth, WheelTooth nextTooth, StringBuilder pathBuilder) { pathBuilder.AppendFormat(CultureInfo.InvariantCulture, " L{0},{1}", (float)tooth.PitchCircleIntersectLeft.X, (float)tooth.PitchCircleIntersectLeft.Y); pathBuilder.AppendFormat( CultureInfo.InvariantCulture, " A{0},{1} 0 0,1 {2},{3}", (float)wheel.AddendumRadius, (float)wheel.AddendumRadius, (float)tooth.Apex.X, (float)tooth.Apex.Y); pathBuilder.AppendFormat( CultureInfo.InvariantCulture, " A{0},{1} 0 0,1 {2},{3}", (float)wheel.AddendumRadius, (float)wheel.AddendumRadius, (float)tooth.PitchCircleIntersectRight.X, (float)tooth.PitchCircleIntersectRight.Y); pathBuilder.AppendFormat( CultureInfo.InvariantCulture, " L{0},{1}", (float)tooth.DedendumIntersectRight.X, (float)tooth.DedendumIntersectRight.Y); double radius = wheel.PitchDiameter / 2.0 - wheel.Dedendum; pathBuilder.AppendFormat( CultureInfo.InvariantCulture, " A{0},{1} 0 0,1 {2},{3}", (float)radius, (float)radius, (float)nextTooth.DedendumIntersectLeft.X, (float)nextTooth.DedendumIntersectLeft.Y); }
internal void Build(Wheel wheel, SvgSvgElement root) { SvgGroupElement helperLinesGroup = new SvgGroupElement("HelperLines"); helperLinesGroup.Style = Styles.HelperLineStyle; root.AddChild(helperLinesGroup); // Wheel pitch circle helperLinesGroup.AddChild(SvgHelper.CreateCircle(wheel.Center, wheel.PitchDiameter / 2.0)); // Wheel addendum circle helperLinesGroup.AddChild(SvgHelper.CreateCircle(wheel.Center, wheel.PitchDiameter / 2.0 + wheel.Addendum)); // Wheel dedendum circle helperLinesGroup.AddChild(SvgHelper.CreateCircle(wheel.Center, wheel.PitchDiameter / 2.0 - wheel.Dedendum)); // wheel center double halfCrossLength = 10; helperLinesGroup.AddChild(new SvgLineElement(wheel.Center.X - halfCrossLength, wheel.Center.Y, wheel.Center.X + halfCrossLength, wheel.Center.Y)); helperLinesGroup.AddChild(new SvgLineElement(wheel.Center.X, wheel.Center.Y - halfCrossLength, wheel.Center.X, wheel.Center.Y + halfCrossLength)); SvgGroupElement mainGroup = new SvgGroupElement("Main"); mainGroup.Style = Styles.MinorLineStyle; root.AddChild(mainGroup); WheelTooth[] teeth = wheel.GetTeeth(0); StringBuilder pathBuilder = new StringBuilder(); pathBuilder.AppendFormat(CultureInfo.InvariantCulture, "M{0},{1}", (float)teeth[0].DedendumIntersectLeft.X, (float)teeth[0].DedendumIntersectLeft.Y); for (int i = 0; i < teeth.Length; i++) { WheelTooth tooth = teeth[i]; WheelTooth nextTooth = teeth[(i + 1) % teeth.Length]; InsertWheelToothPath(wheel, tooth, nextTooth, pathBuilder); } pathBuilder.Append(" z"); SvgPath svgPath = new SvgPath(pathBuilder.ToString()); SvgPathElement svgPathElement = new SvgPathElement(); svgPathElement.D = svgPath; mainGroup.AddChild(svgPathElement); if (wheel.CenterHoleDiameter > 0) { mainGroup.AddChild(SvgHelper.CreateCircle(wheel.Center, wheel.CenterHoleDiameter / 2.0)); } }