Beispiel #1
0
        /// <summary>
        /// Объекдинение накладывающихся зон освещенности/тени
        /// </summary>
        public static List <IIlluminationArea> Merge(List <IIlluminationArea> illums)
        {
            if (illums.Count == 0)
            {
                return(illums);
            }

            List <IIlluminationArea> merged = new List <IIlluminationArea>();
            var sortedByStart = illums.OrderBy(o => o.AngleStartOnPlane).ToList();

            IIlluminationArea cur = sortedByStart[0];

            merged.Add(cur);
            foreach (var ilum in sortedByStart.Skip(1))
            {
                if (ilum.AngleStartOnPlane <= cur.AngleEndOnPlane)
                {
                    if (ilum.AngleEndOnPlane > cur.AngleEndOnPlane)
                    {
                        cur.AngleEndOnPlane = ilum.AngleEndOnPlane;
                        cur.PtEnd           = ilum.PtEnd;
                    }
                }
                else
                {
                    merged.Add(ilum);
                    cur = ilum;
                }
            }
            return(merged);
        }
        /// <summary>
        /// Определение требования освещенности
        /// </summary>
        public InsValue CalcTimeAndGetRate(List <IIlluminationArea> illums, BuildingTypeEnum buildingType)
        {
            if (illums == null)
            {
                return(InsValue.Empty);
            }
            int               maxTimeContinuosIlum = 0;
            int               curContinuosTime     = 0;
            int               totalTime            = 0;
            string            startTime;
            string            endTime;
            IIlluminationArea prev = null;

            foreach (var item in illums)
            {
                item.Time         = CalcTime(item.AngleStartOnPlane, item.AngleEndOnPlane, out startTime, out endTime);
                curContinuosTime += item.Time;
                totalTime        += item.Time;
                item.TimeStart    = startTime;
                item.TimeEnd      = endTime;

                if (prev != null)
                {
                    var interval = CalcTime(prev.AngleEndOnPlane, item.AngleStartOnPlane, out startTime, out endTime);
                    if (interval >= 10)
                    {
                        curContinuosTime = item.Time;
                    }
                }

                if (curContinuosTime > maxTimeContinuosIlum)
                {
                    maxTimeContinuosIlum = curContinuosTime;
                }

                prev = item;
            }

            InsRequirement req      = DefineInsRequirement(maxTimeContinuosIlum, totalTime, buildingType);
            var            insValue = new InsValue(req, maxTimeContinuosIlum, totalTime);

            return(insValue);
        }
Beispiel #3
0
        ///// <summary>
        ///// Построение контура освещенности
        ///// </summary>
        //public override void Create (BlockTableRecord space)
        //{
        //    Point2d pt1 = Point2d.Origin;
        //    Point2d pt2 = Point2d.Origin;
        //    //Low = CreatePl(insService.Options.VisualOptions[0].Height,
        //    //            Color.FromColor(insService.Options.VisualOptions[0].Color), true, ref pt1, ref pt2);
        //    //Medium = CreatePl(insService.Options.VisualOptions[1].Height,
        //    //    Color.FromColor(insService.Options.VisualOptions[1].Color), false, ref pt1, ref pt2);
        //    //Hight = CreatePl(insService.Options.VisualOptions[2].Height,
        //    //    Color.FromColor(insService.Options.VisualOptions[2].Color), false, ref pt1, ref pt2);

        //    Transaction t = space.Database.TransactionManager.TopTransaction;
        //    visualPl(Low, space, t);
        //    visualPl(Medium, space, t);
        //    visualPl(Hight, space, t);
        //}

        public static List <IIlluminationArea> Invert(List <IIlluminationArea> illums,
                                                      IIlluminationArea startAnglesIllumBound, Point2d ptOrig, IInsPoint insPoint)
        {
            double angleStart = startAnglesIllumBound.AngleStartOnPlane;
            double angleEnd   = startAnglesIllumBound.AngleEndOnPlane;
            List <IIlluminationArea> inverts = new List <IIlluminationArea>();

            if (illums.Count == 0)
            {
                // Зон теней нет. От стартового угла до конечного - зона освещена
                var illum = new IllumAreaCentral(insPoint, ptOrig, angleStart, angleEnd,
                                                 GetPointInRayByLength(ptOrig, angleStart, 50),
                                                 GetPointInRayByLength(ptOrig, angleEnd, 50));
                inverts.Add(illum);
            }
            else
            {
                double  curStart   = angleStart;
                Point2d cusStartPt = GetPointInRayFromPoint(illums[0].PtOrig, illums[0].PtStart, curStart);

                foreach (var item in illums)
                {
                    if (item.AngleStartOnPlane - curStart > 0.01)
                    {
                        var illum = new IllumAreaCentral(insPoint, item.PtOrig, curStart, item.AngleStartOnPlane, cusStartPt, item.PtStart);
                        inverts.Add(illum);
                    }
                    curStart   = item.AngleEndOnPlane;
                    cusStartPt = item.PtEnd;
                }
                if (angleEnd - curStart > 0.1)
                {
                    Point2d ptEnd = GetPointInRayFromPoint(illums[0].PtOrig, cusStartPt, angleEnd);
                    var     illum = new IllumAreaCentral(insPoint, illums[0].PtOrig, curStart, angleEnd, cusStartPt, ptEnd);
                    inverts.Add(illum);
                }
            }
            return(inverts);
        }
Beispiel #4
0
        /// <summary>
        /// Определение граничных точек задающих тень по отношению к расчетной точке, среди всех точек
        /// </summary>
        private IIlluminationArea GetIllumShadow(List <Point2d> points)
        {
            IIlluminationArea ilum = null;
            // список точек и их углов к расчетной точке
            var angles = new List <Tuple <Point2d, double> >();

            foreach (var iPt in points)
            {
                // угол к расчетной точке (от 0 по часовой стрелке)
                if (!ptCalc2d.IsEqualTo(iPt))
                {
                    var angle = values.GetInsAngleFromAcad((iPt - ptCalc2d).Angle);
                    angles.Add(new Tuple <Point2d, double>(iPt, angle));
                }
            }
            if (angles.Count > 1)
            {
                angles.Sort((p1, p2) => p1.Item2.CompareTo(p2.Item2));

                ilum = CreateIllumShadow(angles[0], angles[angles.Count - 1]);
            }
            return(ilum);
        }