예제 #1
0
        /// <summary>
        /// CheckGroups - check all groups of elements, put GrType.Warning if group is incorrect
        /// </summary>
        /// <param name="groups"></param>
        public void CheckGroups(ref Model.Model mod)
        {
            if (mod == null || mod.elements == null || mod.elements.Count < 1 ||
                mod.elmGroups == null || mod.elmGroups.Count < 1 ||
                mod.elements.Count != mod.elmGroups.Sum(x => x.guids.Count))
            {
                Msg.F(me + "ChechGroup bad model", mod.name);
            }
            var _dic = mod.elements.ToDictionary(x => x.guid);

            foreach (var gr in mod.elmGroups)
            {
                elmsDic = _dic.Where(x => gr.guids.Contains(x.Value.guid)).ToDictionary(v => v.Key, v => v.Value);
                Mat     = elmsDic.First().Value.mat;
                int  grIndex = mod.elmGroups.IndexOf(gr);
                bool errFlag = false;
                foreach (var elm in elmsDic)
                {
                    if (elm.Value.mat == Mat)
                    {
                        continue;
                    }
                    mod.elmGroups[grIndex].type = GrType.Warning;
                    mod.HighLightElements(elmsDic);
                    if (errFlag)
                    {
                        continue;
                    }
                    Msg.W(me + "CheckGroups various materials in Group"
                          , grIndex, gr.Prf, Mat, elm.Value.mat);
                    errFlag = true;
                }
            }
        }