private static PointClassification ClassifyX(this PointX p, SegmentX s) { var a = s.End - s.Start; var b = p - s.Start; double sa = a.X * b.Y - b.X * a.Y; if (sa > 0.0) { return(PointClassification.LEFT); } if (sa < 0.0) { return(PointClassification.RIGHT); } if ((a.X * b.X < 0.0) || (a.Y * b.Y < 0.0)) { return(PointClassification.BEHIND); } if (a.Length2 < b.Length2) { return(PointClassification.BEYOND); } if (s.Start.Equals(p)) { return(PointClassification.ORIGIN); } if (s.End.Equals(p)) { return(PointClassification.DESTINATION); } return(PointClassification.BETWEEN); }
public PointX GetPoint4MyServer(string bigPicSrc, string smallPicSrc, int smallShiJiY, out PointX bigYuan, out PointX samllYuan) { string bigBase64 = ImageHelper.TakeOutHeand(bigPicSrc); string smallBase64 = ImageHelper.TakeOutHeand(smallPicSrc); PointX p = HuaKuai.GetXY(XmlConfig <SeleniumConfig> .Current.HuaKuaiServer, bigBase64, smallBase64, smallShiJiY, out bigYuan, out samllYuan); long num = HyJiYanCaoZuo.id; HyJiYanCaoZuo.id = num + (long)1; HyJiYanCaoZuo.id = num; ImageHelper.Base64ToImage(bigPicSrc); ImageHelper.Base64ToImage(smallPicSrc); return(p); }
public PointX GetPoint(string bigPicSrc, string smallPicSrc, int smallShiJiY, out PointX bigYuan, out PointX samllYuan) { PointX pointX; PointX p = this.GetPoint4MyServer(bigPicSrc, smallPicSrc, smallShiJiY, out bigYuan, out samllYuan); if ((p == null || bigYuan == null ? false : samllYuan != null)) { p.X = p.X + 18; p.Y = p.Y + 18; pointX = p; } else { pointX = null; } return(pointX); }
private static PointToPolygonPositionType GetPositionToPolygon(this PointX p, PolygonX polygon) { var parity = true; for (var i = 0; i < polygon.Vertices.Length; i++) { var v1 = polygon.Vertices[i]; var v2 = polygon.Vertices[(i + 1) % polygon.Vertices.Length]; var segment = new SegmentX(v1, v2); switch (ClassifyEdgeX(p, segment)) { case EdgeType.TOUCHING: return(PointToPolygonPositionType.Boundary); case EdgeType.CROSSING: parity = !parity; break; } } return(parity ? PointToPolygonPositionType.Outside : PointToPolygonPositionType.Inside); }
public static double EvaluateX(ProblemSpec problemSpec, SolutionSpec solutionSpec, int dpi) { var problemPolygons = problemSpec.Polygons.Select(x => new PolygonX(x)).ToList(); var destPoints = solutionSpec.DestPoints.Select(x => new PointX(x)).ToList(); var allPoints = problemPolygons.SelectMany(x => x.Vertices).Concat(destPoints).ToList(); var minX = allPoints.Min(x => x.X); var minY = allPoints.Min(x => x.Y); var maxX = allPoints.Max(x => x.X); var maxY = allPoints.Max(x => x.Y); var positivePolygons = problemPolygons.Where(p => p.GetSignedSquare() >= 0).ToList(); var negativePolygons = problemPolygons.Where(p => p.GetSignedSquare() < 0).ToList(); var solutionPolygons = solutionSpec.Facets.Select(x => new PolygonX(x.Vertices.Select(v => destPoints[v]).ToArray())).ToList(); var deltaX = (maxX - minX) / dpi; var deltaY = (maxY - minY) / dpi; int intersection = 0; int union = 0; for (var x = minX; x < maxX; x += deltaX) { for (var y = minY; y < maxY; y += deltaY) { var p = new PointX(x, y); var inNegative = negativePolygons.Any(poly => p.GetPositionToPolygon(poly) == PointToPolygonPositionType.Inside); var inPositive = positivePolygons.Any(poly => p.GetPositionToPolygon(poly) != PointToPolygonPositionType.Outside); var inProblem = inPositive && !inNegative; var inSolution = solutionPolygons.Any(poly => p.GetPositionToPolygon(poly) != PointToPolygonPositionType.Outside); if (inProblem && inSolution) { intersection++; } if (inProblem || inSolution) { union++; } } } return(union == 0 ? 0 : (double)intersection / union); }
public PointX GetPoint4LianZhong(string bigPicSrc, string smallPicSrc, out PointX bigYuan, out PointX samllYuan) { int yuanWidth; int yuanHidth; int smW; int smH; byte[] bigPicByte = ImageHelper.Base64ToImage(bigPicSrc, out yuanWidth, out yuanHidth); bigYuan = new PointX() { X = yuanWidth, Y = yuanHidth }; byte[] smallPicByte = ImageHelper.Base64ToImage(smallPicSrc, out smW, out smH); samllYuan = new PointX() { X = smW, Y = smH }; PointX p = null; if ((bigPicByte == null || (int)bigPicByte.Length <= 10 || smallPicByte == null ? false : (int)smallPicByte.Length > 10)) { JsDaTi dtMgr = new JsDaTi(); if (dtMgr.GetZuoBiao(bigPicByte, 1318)) { p = new PointX() { X = dtMgr.offsetX, Y = dtMgr.offsetY }; } } int rd = HelperGeneral.Random.Next(1, 9999999); PicDaTiHelper.SavePic(bigPicByte, "null", string.Format("big_{0}_{1}_{2}", p.X, p.Y, rd), "bmp"); PicDaTiHelper.SavePic(smallPicByte, "null", string.Format("small_{0}_{1}_{2}", p.X, p.Y, rd), "bmp"); return(p); }
private static EdgeType ClassifyEdgeX(PointX a, SegmentX e) { var v = e.Start; var w = e.End; switch (a.ClassifyX(e)) { case PointClassification.LEFT: return(((v.Y < a.Y) && (a.Y <= w.Y)) ? EdgeType.CROSSING : EdgeType.INESSENTIAL); case PointClassification.RIGHT: return(((w.Y < a.Y) && (a.Y <= v.Y)) ? EdgeType.CROSSING : EdgeType.INESSENTIAL); case PointClassification.BETWEEN: case PointClassification.ORIGIN: case PointClassification.DESTINATION: return(EdgeType.TOUCHING); default: return(EdgeType.INESSENTIAL); } }
public bool Run(IWebDriver IframeElWebDriver) { PointX bigYuan; PointX samllYuan; bool isSuc = false; IWebElement bgEl = IframeElWebDriver.FinElement(By.ClassName("bg-placeholder")); IWebElement slideEl = IframeElWebDriver.FinElement(By.Id("slide-block")); IWebElement smallE1 = IframeElWebDriver.FinElement(By.XPath("//div[@id=\"slide-block\"]/img")) ?? IframeElWebDriver.FinElement(By.XPath("/html/body/div[1]/div[2]/div[1]/div[2]/img")); IWebElement bgCanvasEl = IframeElWebDriver.FinElement(By.Id("canvas")); IWebElement dragBtuttonEl = IframeElWebDriver.FinElement(By.ClassName("drag-button")); IWebElement dragTrackEl = IframeElWebDriver.FinElement(By.ClassName("drag-track")); if ((bgEl == null || smallE1 == null || dragBtuttonEl == null ? false : bgCanvasEl != null)) { string smallPicSrc = smallE1.GetAttribute("src"); string bigPicSrc = SelementHelper.ExecJs(IframeElWebDriver, "return document.getElementById('canvas').toDataURL()", Array.Empty <object>()) as string; if ((bigPicSrc == null ? false : smallPicSrc != null)) { int samllLocationY = smallE1.Location.Y - bgCanvasEl.Location.Y; int smallShiJiY = (int)((double)samllLocationY * 1.20805369127517 - 1); PointX p = this.GetPoint(bigPicSrc, smallPicSrc, smallShiJiY, out bigYuan, out samllYuan); if (p != null) { double x = (double)bigYuan.X; Size size = bgEl.Size; double elWidthP = x / (double)size.Width; size = bgEl.Size; double smallYinBig = (double)size.Height / (double)bigYuan.Y; int sjX = HelperGeneral.Random.Next(13, 53); int sjY = HelperGeneral.Random.Next(13, 53); int ysX = sjX; int ysY = sjY; double dianJianP_X = (double)ysX; double tageX_left = (double)p.X / (double)elWidthP; double tageX = tageX_left + dianJianP_X; double k = 0.938; double d = 256 + dianJianP_X - tageX; double realX = tageX - (1 - k) / k * d; int realY = p.Y + sjY; Actions actions = new Actions(IframeElWebDriver); SelementHelper.MoveTo(IframeElWebDriver, smallE1, ysX, ysY); actions.ClickAndHold().Perform(); XTrace.WriteLine("开始移动到{tageX}"); this.MouseMoveTaget((int)realX, realY, actions, dragBtuttonEl, tageX_left, dianJianP_X, slideEl, bgEl, dragTrackEl, IframeElWebDriver); actions.MoveToElement(bgEl, (int)realX, realY).Perform(); Thread.Sleep(2000); double smallLeft = this.GetSmallElLeft(slideEl); double dragLeft = this.GetDragBtuttonElLeft(dragBtuttonEl); if (Math.Abs(realX - dianJianP_X - dragLeft) > 1) { XTrace.WriteLine(string.Format("当前模块位置 {0} 目标位置{1} 小图片当前左上角位置{2}", dragLeft, realX - dianJianP_X, smallLeft)); actions.MoveToElement(bgEl, (int)realX, 20).Perform(); Thread.Sleep(300); } else { XTrace.WriteLine(string.Format("到达目标点{0} 当前按钮位置{1} 小图片当前左上角位置{2} 目的左上角{3}", new object[] { realX - dianJianP_X, dragLeft, smallLeft, tageX_left })); Thread.Sleep(1000); } XTrace.WriteLine("松开鼠标..."); actions.Release().Perform(); Thread.Sleep(2000); isSuc = true; Thread.Sleep(1000); } } } return(isSuc); }
public SegmentX(PointX start, PointX end) { Start = start; End = end; }
/// <summary> /// Draws the content of the line plot area. /// </summary> internal override void Draw() { ChartRendererInfo cri = (ChartRendererInfo)this.rendererParms.RendererInfo; XRect plotAreaRect = cri.plotAreaRendererInfo.Rect; if (plotAreaRect.IsEmpty) { return; } XGraphics gfx = this.rendererParms.Graphics; XGraphicsState state = gfx.Save(); //gfx.SetClip(plotAreaRect, XCombineMode.Intersect); gfx.IntersectClip(plotAreaRect); //TODO null-Values müssen berücksichtigt werden. // Verbindungspunkte können fehlen, je nachdem wie null-Values behandelt werden sollen. // (NotPlotted, Interpolate etc.) // Draw lines and markers for each data series. XMatrix matrix = cri.plotAreaRendererInfo.matrix; double xMajorTick = cri.xAxisRendererInfo.MajorTick; foreach (SeriesRendererInfo sri in cri.seriesRendererInfos) { bool isxy = false; int count = sri.series.Elements.Count; XPoint[] points = new XPoint[count]; double v; PointX px = sri.series.Elements.getPointX(0); if (px != null) { isxy = true; for (int idx = 0; idx < count; idx++) { px = sri.series.Elements.getPointX(idx); if (double.IsNaN(px.yvalue)) { v = 0; } else { v = px.yvalue; } points[idx] = new XPoint(px.xvalue, v); } } if (!isxy) { for (int idx = 0; idx < count; idx++) { v = sri.series.Elements[idx].Value; if (double.IsNaN(v)) { v = 0; } points[idx] = new XPoint(idx + xMajorTick / 2, v); } } matrix.TransformPoints(points); gfx.DrawLines(sri.LineFormat, points); DrawMarker(gfx, points, sri); } //gfx.ResetClip(); gfx.Restore(state); }