Ejemplo n.º 1
0
 public void Parse(ref TMainTreeList AMainTree)
 {
     if (AMainTree != null)
     {
         DoParse(ref AMainTree);
     }
 }
Ejemplo n.º 2
0
 /*       void FillTreeFromList(TListNode* AListNode, int AParentShapeID, TBaseWorkShape* AStart, TBaseWorkShape* AEnd);*/
 public TTreeList()
 {
     f_TreeList       = new TMainTreeList();
     f_TreeList.Level = 0;
     f_Stack          = new TTreeStack();
     f_AltInfo        = new TAltInfo();
 }
Ejemplo n.º 3
0
        public void FillTreeFromList(ref TListNode AListNode)
        {
            TTreeStackItem     Item;
            TAltInfoItem       AltInfoItem;
            TAlternateTreeList AT;
            TNodeMain          Node;
            TTreeListTFS       Tfs;
            TMainTreeList      AMT;
            TMainTreeList      MNew;
            TTreeListItem      LI;

            Init(0);
            Item = f_Stack.GetLevel();
            while (Item != null)
            {
                AMT = FindByLevel(f_TreeList, Item.Level);
                if (AMT != null)
                {
                    AListNode.LoadInfoForAlternate(ref f_AltInfo, Item.Level);
                    for (int i = 0; i <= f_AltInfo.ItemCount - 1; i++)
                    {
                        AltInfoItem        = f_AltInfo.GetItem(i);
                        AT                 = new TAlternateTreeList();
                        AT.MainAlternative = AltInfoItem.Main;
                        AT.NodeStart       = AltInfoItem.NodeStart;
                        AT.NodeEnd         = AltInfoItem.NodeEnd;
                        AT.ID              = AltInfoItem.ID;
                        AT.Num             = AltInfoItem.Num;
                        Node               = AListNode.SearchFirstNodeToAlternate(AltInfoItem.ID, AltInfoItem.Num, Item.Level);
                        while (Node != null)
                        {
                            Tfs = new TTreeListTFS(Node.WorkShape);
                            AT.AddToAlternate(Tfs);
                            for (int j = 0; j <= Tfs.ItemCount - 1; j++)
                            {
                                LI = Tfs.GetTreeTFEItem(j);
                                f_Stack.AddToStack(LI.BaseShape.ID);
                                if (AListNode.IsContainsChildShape(LI.BaseShape.ID))
                                {
                                    if (LI.MainNode == null)
                                    {
                                        MNew        = new TMainTreeList();
                                        MNew.Level  = LI.BaseShape.ID;
                                        LI.MainNode = MNew;
                                    }
                                }
                            }
                            Node = AListNode.SearchNextNodeToAlternate(AltInfoItem.ID, AltInfoItem.Num, Node);
                        }
                        AMT.AddToTree(AT);
                    }
                }
                Item.Fixed = true;
                Item       = f_Stack.GetLevel();
            }
        }
Ejemplo n.º 4
0
        TMainTreeList FindByLevel(TMainTreeList ABegin, int ALevel)
        {
            TMainTreeList Res = null;
            TDynamicArray Dyn = new TDynamicArray();

            Dyn.Append(ABegin);
            int q = 0;

            while (Dyn.GetItems(q) != null)
            {
                Res = (TMainTreeList)(Dyn.GetItems(q));
                for (int i = 0; i <= Res.ItemCount - 1; i++)
                {
                    for (int j = 0; j <= Res.GetAlternateItem(i).ItemCount - 1; j++)
                    {
                        for (int k = 0; k <= Res.GetAlternateItem(i).GetTreeTFSItem(j).ItemCount - 1; k++)
                        {
                            if (Res.GetAlternateItem(i).GetTreeTFSItem(j).GetTreeTFEItem(k).MainNode != null)
                            {
                                Dyn.Append(Res.GetAlternateItem(i).GetTreeTFSItem(j).GetTreeTFEItem(k).MainNode);
                            }
                        }
                    }
                }
                q++;
            }


            for (int i = 0; i <= Dyn.Count - 1; i++)
            {
                Res = (TMainTreeList)(Dyn.GetItems(i));
                if (Res.Level == ALevel)
                {
                    Dyn.Clear();
                    return(Res);
                }
            }
            Dyn.Clear();
            return(null);
        }
Ejemplo n.º 5
0
        /*        void DoMakeAlternative();*/
        void DoParse(ref TMainTreeList AMainTree)
        {
            TAlternativeParserItemBig  mBig, mTemp;
            TAlternativeParserItemBase mBase;

            CreateHead();
            f_Head.MainTreeList = AMainTree;
            f_Head.FillBasisAlternateTreeList(f_Head.MainTreeList.MainAlternative);
            TDynamicArray m_Stack = new TDynamicArray();

            m_Stack.InsertToFirst(f_Head);
            mBig = (TAlternativeParserItemBig)(m_Stack.Pop());
            while (mBig != null)
            {
                if (CheckEnlarge(mBig))
                {
                    MakeBig(ref mBig, f_Head == mBig);
                }
                mBig.Check = true;
                mBig.GetAllFirstBigsNoCheck(m_Stack);
                mBig = (TAlternativeParserItemBig)(m_Stack.Pop());
            }
            m_Stack = null;
        }
Ejemplo n.º 6
0
 public TTreeListItem(TBaseShape ABaseShape)
 {
     f_BaseShape = ABaseShape;
     f_MainNode  = null;
 }
Ejemplo n.º 7
0
        void MakeBig(ref TAlternativeParserItemBig ABig, bool AByPass)
        {
            int                       m_n = 0;
            bool                      b_basis, b_main, b_tail, b_go, b_parent, b_cbm, b_valid = false;
            TTreeListTFS              TFS;
            TAlternateTreeList        AItem;
            TAlternativeParserItemBig NewBig;
            TMainTreeList             m_Tree = ABig.MainTreeList;

            TDynamicArray D      = new TDynamicArray();
            TDynamicArray Mass   = new TDynamicArray();
            bool          m_whl  = true;
            bool          m_hook = false;

            while (m_whl)
            {
                m_whl = false;
                f_Grp.Clear();
                for (int i = 0; i <= ABig.BasisCount - 1; i++)
                {
                    TFS = ABig.GetBasisItems(i);
                    m_Tree.FindAlternate(TFS.BaseWorkShape, D);
                    b_go = false;
                    if (D.Count > 0)
                    {
                        for (int j = 0; j <= D.Count - 1; j++)
                        {
                            AItem    = (TAlternateTreeList)(D.GetItems(j));
                            b_basis  = ABig.CompareBasisAndAlternateTreeList(AItem);
                            b_main   = AItem.MainAlternative;
                            b_tail   = ABig.IsTailAlternateTreeList(AItem);
                            b_parent = ABig.ParentTFE != null;
                            if (!b_basis && !b_main)
                            {
                                Mass.Clear();
                                ABig.GetTreeListTFSFromBasis(AItem, Mass, ref b_valid);
                                if (!b_valid)
                                {
                                    continue;
                                }
                                b_cbm = ABig.CompareBasisAndMassiv(Mass);
                                b_go  = (AByPass || !b_cbm || b_parent);
                                if (b_go)
                                {
                                    CreateParserGrpItemList(Mass, AItem);
                                }
                            }
                            if (b_tail && !b_main && !b_go)
                            {
                                m_n++;
                                NewBig        = new TAlternativeParserItemBig();
                                NewBig.NumAlt = m_n;
                                NewBig.FillBasisAlternateTreeList(AItem);
                                NewBig.OwnerBig = ABig;
                                ABig.AddBig(NewBig);
                            }
                        }
                    }
                    f_Grp.AddTfs(TFS);
                }

                if (ABig.BadBasis && !m_hook)
                {
                    ABig.HookBasisBig();
                    m_hook = true;
                    m_whl  = true;
                }
            }
            f_Grp.Make();
            FillBigFromGrp(ref ABig);
            D    = null;
            Mass = null;
        }
Ejemplo n.º 8
0
 public TAlternativeParserItemBase()
 {
     f_MainTree = null;
     f_OwnerBig = null;
     f_NumAlt   = 0;
 }