public static Vertex CreateVertex(CGPoint p) { if (p == null) { return(null); } var ret = new Vertex() { point = p, e = CGEdge.CreateEdge(p, p.succ), }; if (p.y > p.succ.y && p.y > p.pred.y) { ret.type = CGUtils.ToLeft(p.pred, p.succ, p) ? Type.Split : Type.Start; } else if (p.y < p.succ.y && p.y < p.pred.y) { ret.type = CGUtils.ToLeft(p.pred, p.succ, p) ? Type.Merge : Type.End; } else { ret.type = Type.Normal; } return(ret); }
public CGEdge AddInternalEdge(CGPoint from, CGPoint to) { var ret = CGEdge.CreateEdge(from, to, true); internalEdges.Add(ret); return(ret); }
public override void OnMouseUp(MouseEventArgs e) { var newP = WinManager.Instance.CreatePoint(e.X, CGUtils.ReversedY(e.Y)); if (newP == null) { //var currP = form.currPt; //if (form.Points.Count > 1 && CGUtils.SqrtLength(form.Points[0], currP) < 500) { // form.Points[0].pred = lastP; // lastP.succ = form.Points[0]; // Draw.DrawLine(lastP, form.Points[0]); // Draw.DrawImage(); // lastP = null; //} return; } Draw.DrawPoint(newP); Draw.DrawLine(lastP, newP); var edge = CGEdge.CreateEdge(lastP, newP); edges.Add(edge); lastP.owner = edge; newP.owner = edge; lastP.succ = newP; newP.pred = lastP; lastP = null; }
CGEdge SearchLeftNeighbourEdge(Vertex v) { CGEdge e = CGEdge.CreateEdge(v.point, v.point); var ret = avl.Search(e); (avl.comparer as CGEdge.CGEdgeCompare).n = v.point.y - 0.1f; float x = ret.data.GetX(v.point.y); return(v.point.x > x ? ret.data : ret.Pred.data); }
void TestIntersection(CGEdge a, CGEdge b) { var intersection = CGUtils.Get2DSegmentIntersection(a, b); if (intersection != null) { var p = new Intersection(intersection, a, b); if (!intersections.Contains(p)) { intersections.Add(p); pq.AddEx(p); } } }
public Intersection(CGPoint p, CGEdge a, CGEdge b) : base(p) { type = InecType.Intersec; this.a = a; this.b = b; }
public static CGPoint Get2DSegmentIntersection(CGEdge a, CGEdge b) { return(Get2DSegmentIntersection(a.from, a.to, b.from, b.to)); }