Exemplo n.º 1
0
 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]]);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates constraints and populates the context with points
        /// </summary>
        /// <param name="tcx">The context</param>
        public void Prepare(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);
            }
        }
Exemplo n.º 3
0
 public virtual void Prepare(TriangulationContext tcx)
 {
     if (Triangles == null) {
         Triangles = new List<DelaunayTriangle>(Points.Count);
     } else {
         Triangles.Clear();
     }
     tcx.Points.AddRange(Points);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Creates constraints and populates the context with points
        /// </summary>
        /// <param name="tcx">The context</param>
        public void Prepare( 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);
            }
        }
Exemplo n.º 5
0
 public static void Triangulate(TriangulationAlgorithm algorithm, Triangulatable t)
 {
     TriangulationContext tcx = CreateContext(algorithm);
     tcx.PrepareTriangulation(t);
     Triangulate(tcx);
 }