Exemplo n.º 1
0
    public void UndoRemove()                            //撤销操作,向前,即恢复到后面的操作
    {
        if (mCurOperator == -1)                         //已经回溯到最初始的状态了,不能继续回溯了
        {
            return;
        }

        RemoveOperatorRecord ror = mLstRemoveOperatorRecords[mCurOperator];

        //插入当前操作记录中删除的面片
        LstPatches.Add(ror.Removed);
        ror.Removed.IncreVDegree();                     //顶点度数都增1

        //修改当前顶点数量
        CurVNum -= ror.VNumAdded;

        Patch cur       = null;
        Patch bak       = null;
        Patch patchTemp = new Patch(this);
        int   nNBNum    = ror.LstNeighborBak.Count;

        for (int i = 0; i < nNBNum; i++)
        {
            cur = ror.LstNeighborBak[i].PatchCur;
            bak = ror.LstNeighborBak[i].PatchBak;
            patchTemp.Set(cur);
            cur.Set(bak);
            bak.Set(patchTemp);
        }

        mCurOperator--;                                 //前移一步

        mCurLeastErrorPatch = ror.Removed;              //修改当前误差最小面片
    }
Exemplo n.º 2
0
    public void RedoRemove()                                    //撤销操作,向后,即回溯到以前的操作
    {
        int RemOprCount = mLstRemoveOperatorRecords.Count;

        if (mCurOperator == RemOprCount - 1)            //已经是最后一个操作了,不能再往前恢复了
        {
            return;
        }

        RemoveOperatorRecord ror = mLstRemoveOperatorRecords[mCurOperator + 1];

        //再一次删除当前操作记录中删除的面片,因为前面的恢复过程已经将其插入了
        //注意:该面片应该是被插入在整个listpatch的最后!因为前面的恢复操作,将其插入到尾部了。
        //这样,就可以避免再作一次遍历寻找!
        Patch ptail = LstPatches[LstPatches.Count - 1];

        LstPatches.RemoveAt(LstPatches.Count - 1);
        ror.Removed.DecreVDegree();                     //顶点度数都减1

        //修改当前顶点数量
        CurVNum += ror.VNumAdded;

        Patch cur       = null;
        Patch bak       = null;
        Patch patchTemp = new Patch(this);
        int   nNBNum    = ror.LstNeighborBak.Count;

        for (int i = 0; i < nNBNum; i++)
        {
            cur = ror.LstNeighborBak[i].PatchCur;
            bak = ror.LstNeighborBak[i].PatchBak;
            patchTemp.Set(cur);
            cur.Set(bak);
            bak.Set(patchTemp);
        }

        mCurOperator++;                      //前移一步

        if (mCurOperator == RemOprCount - 1) //后移一步后变成了最后一个操作
        {
            SearchLeastErrorPatch();         //此时要重新计算最小误差面片
        }
        else
        {
            mCurLeastErrorPatch = mLstRemoveOperatorRecords[mCurOperator + 1].Removed;                  //修改当前误差最小面片
        }
    }
Exemplo n.º 3
0
    protected bool RemovePatch(Patch pat)               //删除一个面片
    {
        RemoveOperatorRecord ror = new RemoveOperatorRecord();

        ror.Removed        = pat;
        ror.LstNeighborBak = new List <NeighborBak>();

        //将邻域面片复制并保存好
        Patch             bakNP        = null;
        Patch             curNP        = null;
        List <VPNeighbor> lstNeighbors = pat.LstNeighbors;
        int nbsize = lstNeighbors.Count;
        int i;

        for (i = 0; i < nbsize; i++)
        {
            curNP = lstNeighbors[i].NeighborPatch;
            bakNP = new Patch(curNP);                                   //复制给patchNeighborBak

            //由于要考虑撤销和恢复操作,因此这里似乎不能直接添加到最后!
            //而应改为:将mCurOperator游标其后的所有删除操作删除
            //然后再添加到最后的位置!
            ror.LstNeighborBak.Add(new NeighborBak(curNP, bakNP));
        }

        if (pat.Removed())              //删除成功
        {
            //移除当前面片
            int pos = LstPatches.IndexOf(pat);
            if (pos != -1)
            {
                LstPatches.RemoveAt(pos);
            }

            //记录下来增加的顶点数
            ror.VNumAdded = LstVertecies.Count - CurVNum;
            CurVNum       = LstVertecies.Count;

            //备份操作!
            mLstRemoveOperatorRecords.Add(ror);
            mCurOperator++;
            return(true);
        }

        return(false);
    }