public override void Prepare(TriangulationContext tcx) { base.Prepare(tcx); for (int i = 0; i < EdgeIndex.Length; i += 2) { // XXX: must change!! tcx.NewConstraint(Points[EdgeIndex[i]], Points[EdgeIndex[i + 1]]); } }
public static void Triangulate(TriangulationContext tcx) { switch (tcx.Algorithm) { case TriangulationAlgorithm.DTSweep: default: DTSweep.Triangulate((DTSweepContext)tcx); break; } }
public virtual void PrepareTriangulation(TriangulationContext tcx) { if (Triangles == null) { Triangles = new List <DelaunayTriangle>(Points.Count); } else { Triangles.Clear(); } tcx.Points.AddRange(Points); }
public virtual void PrepareTriangulation(TriangulationContext tcx) { if (Triangles == null) { Triangles = new List<DelaunayTriangle>(Points.Count); } else { Triangles.Clear(); } tcx.Points.AddRange(Points); }
public static void Triangulate(TriangulationAlgorithm algorithm, Triangulatable t) { //long time = System.nanoTime(); TriangulationContext tcx = GetFreeTcxContext(algorithm); tcx.Clear(); //step 1: (3.1) initialization tcx.PrepareTriangulation(t); //step 2: (3.4) sweeping Triangulate(tcx); ReleaseCtxContext(tcx); //logger.info( "Triangulation of {} points [{}ms]", tcx.getPoints().size(), ( System.nanoTime() - time ) / 1e6 ); }
public override void Prepare(TriangulationContext tcx) { if (!Initialize()) { return; } base.Prepare(tcx); Dictionary <uint, TriangulationConstraint> .Enumerator it = _constraintMap.GetEnumerator(); while (it.MoveNext()) { TriangulationConstraint tc = it.Current.Value; tcx.NewConstraint(tc.P, tc.Q); } }
private static void FixupConstrainedEdges(TriangulationContext tcx) { foreach (DelaunayTriangle t in tcx.Triangles) { for (int i = 0; i < 3; ++i) { bool isConstrained = t.GetConstrainedEdgeCCW(t.Points[i]); if (!isConstrained) { DTSweepConstraint edge; bool hasConstrainedEdge = t.GetEdgeCCW(t.Points[i], out edge); if (hasConstrainedEdge) { t.MarkConstrainedEdge((i + 2) % 3); //t.MarkConstrainedEdgeCCW(t.Points[i]); } } } } }
static TriangulationContext GetFreeTcxContext(TriangulationAlgorithm algorithm) { switch (algorithm) { case TriangulationAlgorithm.DTSweep: default: //return context; if (contextStacks.Count == 0) { return(new DTSweepContext()); } else { int last_index = contextStacks.Count - 1; TriangulationContext result = contextStacks[last_index]; contextStacks.RemoveAt(last_index); return(result); } } }
/// <summary> /// Creates constraints and populates the context with points /// </summary> /// <param name="tcx">The context</param> public void PrepareTriangulation(TriangulationContext tcx) { if (_triangles == null) { _triangles = new List <DelaunayTriangle>(_points.Count); } else { _triangles.Clear(); } // Outer constraints for (int i = 0; i < _points.Count - 1; i++) { tcx.NewConstraint(_points[i], _points[i + 1]); } tcx.NewConstraint(_points[0], _points[_points.Count - 1]); tcx.Points.AddRange(_points); // Hole constraints if (_holes != null) { foreach (Polygon p in _holes) { for (int i = 0; i < p._points.Count - 1; i++) { tcx.NewConstraint(p._points[i], p._points[i + 1]); } tcx.NewConstraint(p._points[0], p._points[p._points.Count - 1]); tcx.Points.AddRange(p._points); } } if (_steinerPoints != null) { tcx.Points.AddRange(_steinerPoints); } }
/// <summary>Creates constraints and populates the context with points</summary> /// <param name="tcx">The context</param> public void PrepareTriangulation(TriangulationContext tcx) { if (TrianglesPrivate == null) { TrianglesPrivate = new List <DelaunayTriangle>(PointsPrivate.Count); } else { TrianglesPrivate.Clear(); } // Outer constraints for (int i = 0; i < PointsPrivate.Count - 1; i++) { tcx.NewConstraint(PointsPrivate[i], PointsPrivate[i + 1]); } tcx.NewConstraint(PointsPrivate[0], PointsPrivate[PointsPrivate.Count - 1]); tcx.Points.AddRange(PointsPrivate); // Hole constraints if (HolesPrivate != null) { foreach (Polygon p in HolesPrivate) { for (int i = 0; i < p.PointsPrivate.Count - 1; i++) { tcx.NewConstraint(p.PointsPrivate[i], p.PointsPrivate[i + 1]); } tcx.NewConstraint(p.PointsPrivate[0], p.PointsPrivate[p.PointsPrivate.Count - 1]); tcx.Points.AddRange(p.PointsPrivate); } } if (SteinerPointsPrivate != null) { tcx.Points.AddRange(SteinerPointsPrivate); } }
/// <summary> /// Creates constraints and populates the context with points /// </summary> /// <param name="tcx">The context</param> public void Prepare(TriangulationContext tcx) { if (mTriangles == null) { mTriangles = new List <DelaunayTriangle>(mPoints.Count); } else { mTriangles.Clear(); } // Outer constraints for (int i = 0; i < mPoints.Count - 1; i++) { //tcx.NewConstraint(mPoints[i], mPoints[i + 1]); tcx.NewConstraint(this[i], this[i + 1]); } tcx.NewConstraint(this[0], this[Count - 1]); tcx.Points.AddRange(this); // Hole constraints if (mHoles != null) { foreach (Polygon p in mHoles) { for (int i = 0; i < p.mPoints.Count - 1; i++) { tcx.NewConstraint(p[i], p[i + 1]); } tcx.NewConstraint(p[0], p[p.Count - 1]); tcx.Points.AddRange(p); } } if (mSteinerPoints != null) { tcx.Points.AddRange(mSteinerPoints); } }
public override void PrepareTriangulation(TriangulationContext tcx) { base.PrepareTriangulation(tcx); if (_constrainedPointList != null) { TriangulationPoint p1, p2; List <TriangulationPoint> .Enumerator iterator = _constrainedPointList.GetEnumerator(); while (iterator.MoveNext()) { p1 = iterator.Current; iterator.MoveNext(); p2 = iterator.Current; tcx.NewConstraint(p1, p2); } } else { for (int i = 0; i < EdgeIndex.Length; i += 2) { // XXX: must change!! tcx.NewConstraint(Points[EdgeIndex[i]], Points[EdgeIndex[i + 1]]); } } }
public override void PrepareTriangulation(TriangulationContext tcx) { base.PrepareTriangulation(tcx); if (_constrainedPointList != null) { TriangulationPoint p1, p2; List<TriangulationPoint>.Enumerator iterator = _constrainedPointList.GetEnumerator(); while (iterator.MoveNext()) { p1 = iterator.Current; iterator.MoveNext(); p2 = iterator.Current; tcx.NewConstraint(p1, p2); } } else { for (int i = 0; i < EdgeIndex.Length; i += 2) { // XXX: must change!! tcx.NewConstraint(Points[EdgeIndex[i]], Points[EdgeIndex[i + 1]]); } } }
public TriangulationDebugContext(TriangulationContext tcx) { _tcx = tcx; }
public void Prepare(TriangulationContext tcx) { throw new NotImplementedException("PolyHole.Prepare should never get called"); }
/// <summary> /// Creates constraints and populates the context with points /// </summary> /// <param name="tcx">The context</param> public void PrepareTriangulation(TriangulationContext tcx) { if (_triangles == null) { _triangles = new List<DelaunayTriangle>(_points.Count); } else { _triangles.Clear(); } // Outer constraints for (int i = 0; i < _points.Count - 1; i++) { tcx.NewConstraint(_points[i], _points[i + 1]); } tcx.NewConstraint(_points[0], _points[_points.Count - 1]); tcx.Points.AddRange(_points); // Hole constraints if (_holes != null) { foreach (Polygon p in _holes) { for (int i = 0; i < p._points.Count - 1; i++) { tcx.NewConstraint(p._points[i], p._points[i + 1]); } tcx.NewConstraint(p._points[0], p._points[p._points.Count - 1]); tcx.Points.AddRange(p._points); } } if (_steinerPoints != null) { tcx.Points.AddRange(_steinerPoints); } }
public TriangulationDebugContext(TriangulationContext tcx) { _tcx = tcx; }
protected TriangulationDebugContext(TriangulationContext tcx) { _tcx = tcx; }