//-------------------------------------------------------------------------------------------------- void _ImportEllipse(SvgDomEllipse domEllipse) { var centerPoint = domEllipse.Center; var radiusX = domEllipse.RadiusX; var radiusY = domEllipse.RadiusY; if (radiusX <= 0 || radiusY <= 0) { return; } var rimPointX = domEllipse.RimPointX; var rimPointY = domEllipse.RimPointY; var centerIndex = _AddPoint(centerPoint); var rimIndexX = _AddPoint(rimPointX); var rimIndexY = _AddPoint(rimPointY); _Segments.Add(new SketchSegmentEllipse(centerIndex, rimIndexX, rimIndexY)); }
//-------------------------------------------------------------------------------------------------- void _AddUnconnectableSegment(SketchSegment sketchSegment) { if (sketchSegment is SketchSegmentCircle) { var sketchCircle = (SketchSegmentCircle)sketchSegment; var radius = sketchCircle.Radius(_Sketch.Points); if (radius > 0) { var center = _Sketch.Points[sketchCircle.CenterPoint]; _DomGroup.Children.Add(new SvgDomCircle(center, radius)); return; } } else if (sketchSegment is SketchSegmentEllipse) { var sketchEllipse = (SketchSegmentEllipse)sketchSegment; var curve = sketchEllipse.MakeCurve(_Sketch.Points) as Geom2d_Ellipse; if (curve != null) { var center = _Sketch.Points[sketchEllipse.CenterPoint]; var element = new SvgDomEllipse(center, curve.MajorRadius(), curve.MinorRadius()); var majorAxisPoint = _Sketch.Points[sketchEllipse.GetMajorAxisPoint(_Sketch.Points)]; double rotAngle = new Ax2d(center, new Vec2d(center, majorAxisPoint).ToDir()).Angle(new Ax2d(center, Dir2d.DX)); element.Transforms.Add(new SvgRotateTransform(rotAngle.ToDeg(), element.Center)); _DomGroup.Children.Add(element); return; } } else { Messages.Warning($"Unconnectable segment {_Sketch.Segments.FirstOrDefault(x => x.Value == sketchSegment).Key} of type {sketchSegment.GetType().Name} does not have a method to be exported to a SVG element."); } Messages.Warning($"Unconnectable segment {_Sketch.Segments.FirstOrDefault(x => x.Value == sketchSegment).Key} of type {sketchSegment.GetType().Name} could not be exported to SVG element."); }