Beispiel #1
0
        private static List <Storey> defStoreyNumberType(List <MarkSb> marksSB, int numberFirstFloor)
        {
            var storeysNumberType = new List <Storey>();
            var comparerStorey    = new DoubleEqualityComparer(Settings.Default.StoreyDefineDeviation); // 2000
                                                                                                        // Панели этажные (без чердака и парапета)
            var panelsStoreyNumberType = marksSB.Where(sb => sb.StoreyTypePanel == EnumStorey.Number).SelectMany(sb => sb.MarksAR.SelectMany(ar => ar.Panels)).OrderBy(p => p.InsPt.Y);

            foreach (var panel in panelsStoreyNumberType)
            {
                Storey storey = storeysNumberType.Find(s => comparerStorey.Equals(s.Y, panel.InsPt.Y));
                if (storey == null)
                {
                    // Новый этаж
                    storey = new Storey(panel.InsPt.Y);
                    storeysNumberType.Add(storey);
                    storeysNumberType.Sort((Storey s1, Storey s2) => s1.Y.CompareTo(s2.Y));
                }
                panel.Storey = storey;
            }
            // Нумерация этажей
            int i       = numberFirstFloor;
            var storeys = storeysNumberType.OrderBy(s => s.Y).ToList();

            storeysNumberType.ForEach((s) => s.Number = i++);
            return(storeysNumberType);
        }
Beispiel #2
0
        public void DoubleEqualityComparerTest()
        {
            var dcmp = new DoubleEqualityComparer(1e-4);
            var a    = -0.00050000000000000044;
            var b    = -0.000499999999999997;

            Assert.True(dcmp.Equals(a, b) && dcmp.GetHashCode(a) == dcmp.GetHashCode(b));
        }