private void WriteRoundedRect(Shape shape, RoundedRect roundRect)
 {
     this.outputFileWriter.WriteLine(RectFileStrings.BeginRoundedRect);
     this.outputFileWriter.WriteLine(RectFileStrings.WriteId, shapeToIdMap[shape]);
     this.outputFileWriter.WriteLine(
         RectFileStrings.WriteRoundedRect,
         roundRect.BoundingBox.Left,
         roundRect.BoundingBox.Bottom,
         roundRect.BoundingBox.Width,
         roundRect.BoundingBox.Height,
         roundRect.RadiusX,
         roundRect.RadiusY);
     this.outputFileWriter.WriteLine(RectFileStrings.EndRoundedRect);
 }
 /// <summary>
 /// clones the curve. 
 /// </summary>
 /// <returns>the cloned curve</returns>
 public ICurve Clone() {
     RoundedRect newRect = new RoundedRect();
     newRect.RadiusX = this.RadiusX;
     newRect.RadiusY = this.RadiusY;
     newRect.curve = (Curve)this.curve.Clone();
     return newRect;
 }
        public void CircleLineCross() {
            //  DisplayGeometryGraph.SetShowFunctions();

            const double chordLen = 1.5;
            const int cy = 3;
            const double cx = chordLen / 2;
            var r = Math.Sqrt(cy * cy + cx * cx);
            var center = new Point(cx, cy);
            var circle = new Ellipse(r, r, center);
            var a = new Point(-10, 0);
            var b = new Point(10, 0);
            var ca = a - center;
            var cb = b - center;
            const double angle = Math.PI / 6;
            ca = ca.Rotate(angle);
            cb = cb.Rotate(angle);
            a = center + ca;
            b = center + cb;
            var lineSeg = new LineSegment(a, b);
            var ii = Curve.GetAllIntersections(lineSeg, circle, true);
            //            DisplayGeometryGraph.ShowDebugCurves(new DebugCurve(100,0.01,"black", lineSeg), new DebugCurve(100,0.01,"blue", circle));
            Assert.IsTrue(ii.Count == 2);

            var roundedRect = new RoundedRect(new Rectangle(0, 100, 200, 0), 10, 10);
            lineSeg = new LineSegment(0, 0, 200, 100);
            //   DisplayGeometryGraph.ShowDebugCurves(new DebugCurve(100, 0.01, "black", lineSeg), new DebugCurve(100, 0.01, "blue", roundedRect));
            ii = Curve.GetAllIntersections(lineSeg, roundedRect, true);
            Assert.IsTrue(ii.Count == 2);

            lineSeg = new LineSegment(0, 100, 200, 0);
            // DisplayGeometryGraph.ShowDebugCurves(new DebugCurve(100, 0.01, "black", lineSeg), new DebugCurve(100, 0.01, "blue", roundedRect));            
            ii = Curve.GetAllIntersections(lineSeg, roundedRect, true);
            Assert.IsTrue(ii.Count == 2);

            lineSeg = new LineSegment(-2.05, 92.9, 8.27, 103.0);
            // DisplayGeometryGraph.ShowDebugCurves(new DebugCurve(100, 0.01, "black", lineSeg), new DebugCurve(100, 0.01, "blue", roundedRect));
            ii = Curve.GetAllIntersections(lineSeg, roundedRect, true);
            Assert.IsTrue(ii.Count == 0);

            var d = 10 * (Math.Sqrt(2) - 1) * Math.Sqrt(2);

            lineSeg = new LineSegment(d, 0, 0, d);
            var seg =
                roundedRect.Curve.Segments.Where(s => s is Ellipse).Select(s => (Ellipse)s).Where(
                    e => e.Center.X < 11 && e.Center.Y < 11).First();
            // DisplayGeometryGraph.ShowDebugCurves(new DebugCurve(100, 0.01, "black", lineSeg), new DebugCurve(100, 0.01, "blue", seg));
            ii = Curve.GetAllIntersections(lineSeg, seg, true);

            Assert.IsTrue(ii.Count == 1);


        }
 static IList<IntersectionInfo> GetAllIntersectionsOfLineAndRoundedRect(LineSegment lineSeg, RoundedRect roundedRect, bool liftIntersections) {
     var ret = GetAllIntersectionsOfLineAndCurve(lineSeg, roundedRect.Curve, liftIntersections);
     if(liftIntersections)
         foreach (var intersectionInfo in ret) {
             intersectionInfo.Segment1 = roundedRect;
         }
     return ret;
 }
        public void LineSegmentCurveIntersectionTest() {
            //DisplayGeometryGraph.SetShowFunctions();

            LineSegment ls = new LineSegment(new Point(4099.7139171825129, 3574.8416020767831), new Point(3799.4470573258791, 3413.5396137128196));
            Rectangle rect = new Rectangle(new Point(3896.7207486979, 3441.1203417969), new Point(3956.1474153646, 3467.0803417969));
            RoundedRect rr = new RoundedRect(rect, 3, 3);
            var inters = Curve.GetAllIntersections(ls, rr, true);

            //List<DebugCurve> dc = new List<DebugCurve>();
            //dc.Add(new DebugCurve(0.01, rr));
           // dc.Add(new DebugCurve(0.01, ls));
           // LayoutAlgorithmSettings.ShowDebugCurvesEnumeration(dc);

            Assert.IsTrue(inters.Count == 2);
        }