Пример #1
0
        public override void prepareTriangulation(TriangulationContext tcx)
        {
            base.prepareTriangulation(tcx);
            if (_constrainedPointList != null)
            {
                TriangulationPoint p1, p2;
                for (int i = 0; i < _constrainedPointList.Count; i += 2)
                {
                    p1 = _constrainedPointList[i];
                    p2 = _constrainedPointList[i + 1];
                    tcx.newConstraint(p1, p2);
                }

                //    Iterator iterator = _constrainedPointList.iterator();
                //while (iterator.hasNext())
                //{
                //    p1 = (TriangulationPoint)iterator.next();
                //    p2 = (TriangulationPoint)iterator.next();
                //    tcx.newConstraint(p1, p2);
                //}
            }
            else
            {
                for (int i = 0; i < _index.Length; i += 2)
                {
                    // XXX: must change!!
                    tcx.newConstraint(_points[_index[i]], _points[_index[i + 1]]);
                }
            }
        }
Пример #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);
            }
        }