/// <summary> /// Returns the neighbors that shares the given corner and is not the previous triangle. /// </summary> /// <param name="p">The given corner.</param> /// <param name="prevTriangle">The previous triangle.</param> /// <returns>The neighbors that shares the given corner and is not the previous triangle.</returns> public object nextNeighbor(Point_dt p, Triangle_dt prevTriangle) { Triangle_dt neighbor = null; if (_a.Equals(p)) { neighbor = _canext; } else if (_b.Equals(p)) { neighbor = _abnext; } else if (_c.Equals(p)) { neighbor = _bcnext; } if (neighbor.Equals(prevTriangle) | neighbor.isHalfplane) { if (_a.Equals(p)) { neighbor = _abnext; } else if (_b.Equals(p)) { neighbor = _bcnext; } else if (_c.Equals(p)) { neighbor = _canext; } } return(neighbor); }
public void insertPoint(Point_dt p) { if (_vertices.Contains(p)) { return; } _modCount += 1; updateBoundingBox(p); _vertices.Add(p); Triangle_dt t = insertPointSimple(p); if (t == null) { return; } Triangle_dt tt = t; currT = t; // recall the last point for fast (last) update iterator do { Flip(tt, _modCount); tt = tt.canext; } while (tt.Equals(t) & !tt.isHalfplane); if ((gridIndex != null)) { gridIndex.updateIndex(getLastUpdatedTriangles()); } }
public void switchneighbors(Triangle_dt old_t, Triangle_dt new_t) { if (_abnext.Equals(old_t)) { _abnext = new_t; } else if (_bcnext.Equals(old_t)) { _bcnext = new_t; } else if (_canext.Equals(old_t)) { _canext = new_t; } else { Console.WriteLine("Error, switchneighbors can't find Old."); } }
private void insertCollinear(Point_dt p, int res) { Triangle_dt t = default(Triangle_dt); Triangle_dt tp = default(Triangle_dt); Triangle_dt u = default(Triangle_dt); switch (res) { case Point_dt.INFRONTOFA: t = new Triangle_dt(firstP, p); tp = new Triangle_dt(p, firstP); t.abnext = tp; tp.abnext = t; t.bcnext = tp; tp.canext = t; t.canext = firstT; firstT.bcnext = t; tp.bcnext = firstT.abnext; firstT.abnext.canext = tp; firstT = t; firstP = p; break; // TODO: might not be correct. Was : Exit Select break; case Point_dt.BEHINDB: t = new Triangle_dt(p, lastP); tp = new Triangle_dt(lastP, p); t.abnext = tp; tp.abnext = t; t.bcnext = lastT; lastT.canext = t; t.canext = tp; tp.bcnext = t; tp.canext = lastT.abnext; lastT.abnext.bcnext = tp; lastT = t; lastP = p; break; // TODO: might not be correct. Was : Exit Select break; case Point_dt.ONSEGMENT: u = firstT; while (p.isGreater(u.a)) { u = u.canext; } t = new Triangle_dt(p, u.b); tp = new Triangle_dt(u.b, p); u.b = p; u.abnext.a = p; t.abnext = tp; tp.abnext = t; t.bcnext = u.bcnext; u.bcnext.canext = t; t.canext = u; u.bcnext = t; tp.canext = u.abnext.canext; u.abnext.canext.bcnext = tp; tp.bcnext = u.abnext; u.abnext.canext = tp; if ((firstT.Equals(u))) { firstT = t; } break; // TODO: might not be correct. Was : Exit Select break; } }