Exemplo n.º 1
0
 public virtual void prepareTriangulation(TriangulationContext tcx)
 {
     if (_triangles == null)
     {
         _triangles = new List <DelaunayTriangle>(_points.Count);
     }
     else
     {
         _triangles.Clear();
     }
     tcx.addPoints(_points);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates constraints and populates the context with points
        /// </summary>
        public void prepareTriangulation(TriangulationContext tcx)
        {
            if (m_triangles == null)
            {
                m_triangles = new List <DelaunayTriangle>(_points.Count);
            }
            else
            {
                m_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.addPoints(_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.addPoints(p._points);
                }
            }

            if (_steinerPoints != null)
            {
                tcx.addPoints(_steinerPoints);
            }
        }