예제 #1
0
        /// <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
            int pCount = mPoints.Count - 1;

            for (int i = 0; i < pCount; i++)
            {
                //tcx.NewConstraint(mPoints[i], mPoints[i + 1]);
                tcx.NewConstraint(this [i], this [i + 1]);
            }
            tcx.NewConstraint(this [Count - 1], this [0]);              // Changed by Kronnect Games
//			tcx.NewConstraint (this [0], this [Count - 1]);

            tcx.Points.AddRange(this);

            // Hole constraints
            if (mHoles != null)
            {
                foreach (Polygon p in mHoles)
                {
                    int mPointsCount = p.mPoints.Count - 1;
                    for (int i = 0; i < mPointsCount; i++)
                    {
                        tcx.NewConstraint(p [i], p [i + 1]);
                    }
                    tcx.NewConstraint(p [p.Count - 1], p[0]);                      // Changed by Kronnect Games
//					tcx.NewConstraint (p [0], p [p.Count - 1]);
                    tcx.Points.AddRange(p);
                }
            }

            if (mSteinerPoints != null)
            {
                tcx.Points.AddRange(mSteinerPoints);
            }
        }
        public override void Prepare(TriangulationContext tcx)
        {
            if (!Initialize())
            {
                return;
            }

            base.Prepare(tcx);

            Dictionary <uint, TriangulationConstraint> .Enumerator it = mConstraintMap.GetEnumerator();
            while (it.MoveNext())
            {
                TriangulationConstraint tc = it.Current.Value;
                tcx.NewConstraint(tc.P, tc.Q);
            }
        }