Exemple #1
0
        public void Split(int ie)
        {
            if (!(ie > i_Begin && ie < i_End))
            {
                throw new Exception(string.Format("In split ie= {0}, i_Begin = {1}, i_End = {2}", ie, i_Begin, i_End));
            }
            //Debug.Assert(ie > i_Begin && ie < i_End);
            PHullOp PHOp = this.StackOp.First();

            while (this.StackOp.Count > 0 && (PHOp.Pt_i != ie || PHOp.Op != eOp.Push))
            {
                this.StackOp.Pop();
                switch (PHOp.Op)
                {
                case eOp.Push:
                    Top--;
                    Bot++;
                    break;

                case eOp.Top:
                    Elt[++Top] = PHOp.Pt_i;
                    break;

                case eOp.Bot:
                    Elt[--Bot] = PHOp.Pt_i;
                    break;

                default:
                    break;
                }
                PHOp = this.StackOp.First();
            }
        }
Exemple #2
0
        public PathHullStack Copy()
        {
            PathHullStack ph = new PathHullStack()
            {
            };

            ph.Pts     = this.Pts;
            ph.i_Begin = this.i_Begin;
            ph.i_End   = this.i_End;
            ph.HMax    = this.HMax;
            ph.Top     = this.Top;
            ph.Bot     = this.Bot;
            //ph.Hp = this.Hp;
            ph.Elt = new int[2 * HMax];
            //ph.HElt = new int[3 * HMax];
            //ph.Op = new eStackOp[3 * HMax];
            //for (int i = 0; i <= this.Hp; i++) {
            //    ph.Op[i] = this.Op[i];
            //    ph.HElt[i] = this.HElt[i];
            //}
            // Clone stackb
            var arr = new PHullOp[this.StackOp.Count];

            this.StackOp.CopyTo(arr, 0);
            Array.Reverse(arr);
            ph.StackOp = new Stack <PHullOp>(arr);
            // Clone stacke

            for (int i = this.Bot; i <= this.Top; i++)
            {
                ph.Elt[i] = this.Elt[i];
            }
            //this.Elt.CopyTo(ph.Elt, 0);
            //this.HElt.CopyTo(ph.HElt, 0);
            //this.Op.CopyTo(ph.Op, 0);
            ph.isLeft = this.isLeft;
            return(ph);
        }