Пример #1
0
        void test_Mtch_3()
        {
            Log.set(" test_Mtch_3: Rule 5 и Group < C235, Pl30 >");
            rule = new Rule.Rule(5);
            ElmAttSet.ElmAttSet elm = new ElmAttSet.ElmAttSet(
                "ID56A7442F-0000-0D74-3134-353338303236",
                "C235", "Steel", "Pl30", 0, 0, 0, 1001);
            Dictionary<string, ElmAttSet.ElmAttSet> els
                = new Dictionary<string, ElmAttSet.ElmAttSet>();
            els.Add(elm.guid, elm);
            List<string> guids = new List<string>(); guids.Add(elm.guid);
            var model = new Model.Model();
            model.setElements(els);
            model.getGroups();
            var gr = model.elmGroups[0];
            //6/4/17           TST.Eq(gr.guids.Count, 1);
            //6/4/17           TST.Eq(gr.mat, "c235");
            //6/4/17TST.Eq(gr.prf, "pl30");
            var doc = Docs.getDoc("Полоса СтальхолдингM");
            var csDP = new Dictionary<SType, string>();
            //31/3            csFPs = rule.Parser(FP.type.CompSet, doc.LoadDescription);
            // 2/4            Comp comp1 = new Comp(doc, 2, csDP);
            // 2/4            Comp comp2 = new Comp(doc, 12, csDP);
            // 2/4            List<Comp> comps = new List<Comp> { comp1, comp2 };
            // 2/4            CS cs = new CS("test_CS", null, rule, doc.LoadDescription, comps);
            // 2/4            TST.Eq(cs.csDP.Count, 4);

            //////////////////////////TST.Eq(comp1.isMatch(gr, rule), false);
            //////////////////////////TST.Eq(comp2.isMatch(gr, rule), true);
            Log.exit();
        }
Пример #2
0
        void test_Mtch_2()
        {
            Log.set(" test_Mtch_2: Rule 15 и Group < B12,5 , 1900x1600 > ");
            rule = new Rule.Rule(15);
            ElmAttSet.ElmAttSet elB = new ElmAttSet.ElmAttSet(
                "ID56A7442F-0000-0D7B-3134-353338303236",
                "B12,5", "Concrete", "1900x1600", 0, 0, 0, 1000);
            Dictionary <string, ElmAttSet.ElmAttSet> els = new Dictionary <string, ElmAttSet.ElmAttSet>();

            els.Add(elB.guid, elB);
            List <string> guids = new List <string>(); guids.Add(elB.guid);
            var           model = new Model.Model();

            model.setElements(els);
            model.getGroups();
            var gr = model.elmGroups[0];

            TST.Eq(gr.guids.Count, 1);
            var match = new Mtch(gr, rule);

            TST.Eq(match.ok == OK.Match, true);
            var cmp = match.component;

//31/3            TST.Eq(cmp.fps[SType.Material].pars[0].par.ToString(), "b12,5");
            Log.exit();
        }
Пример #3
0
        public void getGroups(List<Elm> elements)
        {
            elmMgroups.Clear();
            elmGroups.Clear();
            Dictionary<string, ElmAttSet.ElmAttSet> Elements = new Dictionary<string, ElmAttSet.ElmAttSet>();
            try { Elements = elements.ToDictionary(elm => elm.guid); }
            catch { Msg.F("Model.getGroups inconsystent elements "); }

            //-- группы по Материалам elm.mat
            var matGroups = from elm in elements group elm by elm.mat;
            foreach (var matGr in matGroups)
            {
                List<string> guids = new List<string>();
                foreach (ElmAttSet.ElmAttSet element in matGr)
                {
                    //                      log.Info("mgr.mat=" + matGr.Key + " mgr.element.guid=" + element.guid);
                    guids.Add(element.guid);
                }
                ElmAttSet.Mgroup Mgr = new ElmAttSet.Mgroup(elements, matGr.Key, guids);
                elmMgroups.Add(Mgr);
            }
            log.Info("----- Material Groups Count = " + elmMgroups.Count + "\tfrom " + elements.Count + " elements ----");
            foreach (var mtGr in elmMgroups)
                log.Info("material= " + mtGr.mat + "\tCount= " + mtGr.guids.Count + "\tвес=" + mtGr.totalWeight + "\tобъем=" + mtGr.totalVolume);

            //-- группы по Материалу и Профилю elm.mat && elm.prf
            foreach (var Mgr in elmMgroups)
            {
                string curMat = Mgr.mat;
                //7/6                string curPrf = Lib.ToLat(Elements[Mgr.guids[0]].prf.ToLower());
                string curPrf = Elements[Mgr.guids[0]].prf;
                List<string> guids = new List<string>();
                foreach (var g in Mgr.guids)
                {
                    ElmAttSet.ElmAttSet elm = Elements[g];
                    if (elm.prf == curPrf) guids.Add(g);
                    else
                    {
                        elmGroups.Add(new ElmGr(Elements, curMat, curPrf, guids));
                        curPrf = elm.prf;
                        guids = new List<string>();
                        guids.Add(g);
                    }
                }
                if (guids.Count != 0) elmGroups.Add(new ElmGr(Elements, curMat, curPrf, guids));
            }

            elmGroups = PrfUpdate(elmGroups);
//26/6            PrfUpdate();

            log.Info("----- <Material, Profile> Groups Count = " + this.elmGroups.Count);
            int chkSum = 0;
            foreach (var gr in this.elmGroups)
            {
                log.Info("material= " + gr.mat + "\tprofile= " + gr.prf + "\tCount= " + gr.guids.Count);
                chkSum += gr.guids.Count;
            }
            log.Info("-------------- CheckSum: total elements count in all groups = " + chkSum);
        }
Пример #4
0
        //////////////        private void test_getSectionText()
        //////////////        {
        //////////////            Log.set("test_getSectionTest(Section.Material, text");
        //28/5/////////////// 7/3/2017 /////////////////            TST.Eq(getSectionText(FP.Section.Material, "Профиль: L 20 x 5; M: C245; Price: 2690"), "c245");
        //////////////            Log.exit();
        //////////////        }

        //////////////private void test_isSectionMatch()
        //////////////{
        //////////////    Log.set("isSectionMatch(Section.Material, C245, rule.text)");

        //////////////    /////// 7/3/2017 ////            bool ok = isSectionMatch(FP.Section.Material, "C245", "Профиль: L * x * ст*; длина: * = * м; M: ст *;");

        //////////////    Log.exit();
        //////////////}

        private void test_Mtch_1()
        {
            Log.set(" test_Mtch_1: Rule 4 и Group<C255, L20x4>");
            Rule.Rule rule = new Rule.Rule(4);
            ElmAttSet.ElmAttSet el = new ElmAttSet.ElmAttSet(
                "ID56A7442F-0000-0D70-3134-353338303236",
                "C245", "Steel", "Уголок20X4", 0, 0, 0, 1000);
            Dictionary<string, ElmAttSet.ElmAttSet> els = new Dictionary<string, ElmAttSet.ElmAttSet>();
            els.Add(el.guid, el);
            List<string> guids = new List<string>(); guids.Add(el.guid);
            Group.Group gr = new Group.Group(els, "C245", "Уголок20X4", guids);
            Mtch match = new Mtch(gr, rule);
            //6/4/17            TST.Eq(match.ok == OK.Match, true);
            Log.exit();
        }
Пример #5
0
        private static List <ElmAttributes.ElmAttSet> MergeIfcToElmAttSet(List <IfcManager.Core.IfcManager.IfcElement> elements)
        {
            foreach (var ifc_elm in elements)
            {
                string guid = ifc_elm.guid;
                if (!ElmAttSet.ElmAttSet.Elements.ContainsKey(guid))
                {
                    ElmAttSet.ElmAttSet new_elm = new ElmAttSet.ElmAttSet(ifc_elm);
//                    new_elm = new ElmAttSet.ElmAttSet(ifcElemOrg);
                }
                else
                {
                    ElmAttributes.ElmAttSet elm = null;
                    ElmAttSet.ElmAttSet.Elements.TryGetValue(guid, out elm);
                    if (!String.IsNullOrEmpty(ifc_elm.material))
                    {
                        elm.mat = ifc_elm.material;
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.type_material))
                    {
                        elm.mat_type = ifc_elm.type_material;
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.profile))
                    {
                        elm.prf = ifc_elm.profile;
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.length))
                    {
                        elm.length = Lib.ToDouble(ifc_elm.length);
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.weight))
                    {
                        elm.weight = Lib.ToDouble(ifc_elm.weight);
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.volume))
                    {
                        elm.volume = Lib.ToDouble(ifc_elm.volume);
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.price))
                    {
                        elm.price = Lib.ToDouble(ifc_elm.price);
                    }
                }
            }
            return(ElmAttSet.ElmAttSet.Elements.Values.ToList());
        }
Пример #6
0
        /// <summary>
        /// getGroups() - groupping of elements of Model by Material and Profile
        /// </summary>
        /// <ToDo>30.9.2016 - попробовать перенести этот метод в ElmAttSet.Groups</ToDo>
        /// <history> 2016.09.29 </history>
        public void getGroups()
        {
            Dictionary <string, ElmAttSet.ElmAttSet> Elements = new Dictionary <string, ElmAttSet.ElmAttSet>();

            foreach (var elm in elements)
            {
                Elements.Add(elm.guid, elm);
            }

            //-- группы по Материалам elm.mat
            var matGroups = from elm in elements group elm by elm.mat;

            foreach (var matGr in matGroups)
            {
                List <string> guids = new List <string>();
                foreach (ElmAttSet.ElmAttSet element in matGr)
                {
                    //                      log.Info("mgr.mat=" + matGr.Key + " mgr.element.guid=" + element.guid);
                    guids.Add(element.guid);
                }
                ElmAttSet.Mgroup Mgr = new ElmAttSet.Mgroup(elements, matGr.Key, guids);
                elmMgroups.Add(Mgr);
            }
            log.Info("----- Material Groups Count = " + elmMgroups.Count + "\tfrom " + elements.Count + " elements ----");
            foreach (var mtGr in elmMgroups)
            {
                log.Info("material= " + mtGr.mat + "\tCount= " + mtGr.guids.Count + "\tвес=" + mtGr.totalWeight + "\tобъем=" + mtGr.totalVolume);
            }

            //-- группы по Материалу и Профилю elm.mat && elm.prf
            this.elmGroups.Clear();
            foreach (var Mgr in elmMgroups)
            {
                string        curMat = Mgr.mat;
                string        curPrf = Elements[Mgr.guids[0]].prf;
                List <string> guids  = new List <string>();
                foreach (var g in Mgr.guids)
                {
                    ElmAttSet.ElmAttSet elm = Elements[g];
                    if (elm.prf == curPrf)
                    {
                        guids.Add(g);
                    }
                    else
                    {
                        this.elmGroups.Add(new ElmGr(Elements, curMat, curPrf, guids));
                        curPrf = elm.prf;
                        guids  = new List <string>();
                        guids.Add(g);
                    }
                }
                if (guids.Count != 0)
                {
                    this.elmGroups.Add(new ElmGr(Elements, curMat, curPrf, guids));
                }
            }
            log.Info("----- <Material, Profile> Groups Count = " + this.elmGroups.Count);
            int chkSum = 0;

            foreach (var gr in this.elmGroups)
            {
                log.Info("material= " + gr.mat + "\tprofile= " + gr.prf + "\tCount= " + gr.guids.Count);
                chkSum += gr.guids.Count;
            }
            log.Info("-------------- CheckSum: total elements count in all groups = " + chkSum);
        }