internal void Build(Pinion pinion, SvgSvgElement root) { SvgGroupElement helperLinesGroup = new SvgGroupElement("HelperLines"); helperLinesGroup.Style = Styles.HelperLineStyle; root.AddChild(helperLinesGroup); // Wheel pitch circle helperLinesGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.PitchDiameter / 2.0)); // Wheel addendum circle helperLinesGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.PitchDiameter / 2.0 + pinion.Addendum)); // Wheel dedendum circle helperLinesGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.PitchDiameter / 2.0 - pinion.Dedendum)); // wheel center double halfCrossLength = 10; helperLinesGroup.AddChild(new SvgLineElement(pinion.Center.X - halfCrossLength, pinion.Center.Y, pinion.Center.X + halfCrossLength, pinion.Center.Y)); helperLinesGroup.AddChild(new SvgLineElement(pinion.Center.X, pinion.Center.Y - halfCrossLength, pinion.Center.X, pinion.Center.Y + halfCrossLength)); SvgGroupElement mainGroup = new SvgGroupElement("Main"); mainGroup.Style = Styles.MinorLineStyle; root.AddChild(mainGroup); PinionTooth[] teeth = pinion.GetTeeth(Math.PI / pinion.ToothCount); 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++) { PinionTooth tooth = teeth[i]; PinionTooth nextTooth = teeth[(i + 1) % teeth.Length]; InsertToothPath(pinion, tooth, nextTooth, pathBuilder); } pathBuilder.Append(" z"); SvgPath svgPath = new SvgPath(pathBuilder.ToString()); SvgPathElement svgPathElement = new SvgPathElement(); svgPathElement.D = svgPath; mainGroup.AddChild(svgPathElement); if (pinion.CenterHoleDiameter > 0) { mainGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.CenterHoleDiameter / 2.0)); } }
private void AddSlice(SvgGroupElement group, double radius, double angle, double angularWidth) { PointF firstPointOnCircle = GetPointOnCircle(radius, angle - angularWidth / 2.0); PointF secondPointOnCircle = GetPointOnCircle(radius, angle + angularWidth / 2.0); // for an explanation of the arc syntax see: http://www.codestore.net/store.nsf/unid/EPSD-5DTT4L string path = String.Format( CultureInfo.InvariantCulture, "M0,0 L{0},{1} A{2},{2} 0 0,1 {3},{4} z", firstPointOnCircle.X, firstPointOnCircle.Y, (float)radius, secondPointOnCircle.X, secondPointOnCircle.Y); SvgPath svgPath = new SvgPath(path); SvgPathElement svgPathElement = new SvgPathElement(); svgPathElement.D = svgPath; group.AddChild(svgPathElement); }