public void ConvertingTwoTouchingRectanglesProducesInvalidMultipolygon() { var sg = new StreamGeometry(); using (var ctx = sg.Open()) { ctx.BeginFigure(new WpfPoint(0, 0), true, true); ctx.LineTo(new WpfPoint(0, 10), true, false); ctx.LineTo(new WpfPoint(10, 10), true, false); ctx.LineTo(new WpfPoint(10, 0), true, false); ctx.LineTo(new WpfPoint(0, 0), true, false); ctx.BeginFigure(new WpfPoint(10, 5), true, true); ctx.LineTo(new WpfPoint(10, 15), true, false); ctx.LineTo(new WpfPoint(20, 15), true, false); ctx.LineTo(new WpfPoint(20, 5), true, false); ctx.LineTo(new WpfPoint(10, 5), true, false); } sg.Freeze(); var area = sg.GetArea(); var geometry = WpfGeometryReader.Read(sg, Geometries.GeometryFactory.Default); Assert.AreEqual(area, geometry.Area, 1e-4); }
public void ConvertingARectangleWithAHoleProducesInvalidMultipolygon() { var sg = new StreamGeometry(); using (var ctx = sg.Open()) { ctx.BeginFigure(new WpfPoint(0, 0), true, true); ctx.LineTo(new WpfPoint(0, 10), true, false); ctx.LineTo(new WpfPoint(10, 10), true, false); ctx.LineTo(new WpfPoint(10, 0), true, false); ctx.LineTo(new WpfPoint(0, 0), true, false); ctx.BeginFigure(new WpfPoint(4, 4), true, true); ctx.LineTo(new WpfPoint(4, 6), true, false); ctx.LineTo(new WpfPoint(6, 6), true, false); ctx.LineTo(new WpfPoint(6, 4), true, false); ctx.LineTo(new WpfPoint(4, 4), true, false); } sg.Freeze(); var area = sg.GetArea(); var geometry = WpfGeometryReader.Read(sg, Geometries.GeometryFactory.Default); Assert.AreEqual(area, geometry.Area, 1e-4); // Fails. Area is 104. }
//--------------------------------------------------------------------------------------------------------- /// <summary> /// Вычисление площади графического примитива /// </summary> /// <returns>Площадь графического примитива</returns> //--------------------------------------------------------------------------------------------------------- public override Double ComputeArea() { return(mGeometry.GetArea()); }