Пример #1
0
        public void Valuing(ConflictElement conflictElement, List <ValuedConflictNode> valuedConflictNodes, List <AvoidElement> avoidElements)
        {
            if (ConflictLineSections.IsValued)
            {
                return;
            }

            SetupAvoidPriorityValue(valuedConflictNodes);
            ConflictLineSections.IsValued = true;
        }
Пример #2
0
 internal ConflictElement AddConflictElement(ConflictElement conflictElement)
 {
     if (ConflictElements == null)
     {
         ConflictElements = new List <ConflictElement>();
     }
     ConflictElements.Add(conflictElement);
     SortConflictElements();
     return(conflictElement);
 }
Пример #3
0
        static double GroupingDistance = PmSoft.Common.RevitClass.Utils.UnitTransUtils.MMToFeet(300);//成组的最小距离

        /// <summary>
        /// 价值分析
        /// 组团+价值计算
        /// 基本逻辑:
        /// 找到原始碰撞单元
        /// 连续组团处理
        /// 边界连接件组团处理
        /// 价值计算
        /// </summary>
        /// <param name="conflictElement"></param>
        /// <param name="valuedConflictNodes">源碰撞</param>
        /// <param name="avoidElements">源碰撞</param>

        public void Grouping(ConflictElement conflictElement, List <ValuedConflictNode> valuedConflictNodes, List <AvoidElement> avoidElements)
        {
            if (ConflictLineSections.IsGrouped)
            {
                return;
            }

            ConflictLineSections = new ConflictLineSections();
            SetupGroup(OrientAvoidElement, conflictElement, valuedConflictNodes, avoidElements);
            RenderGroupInfo(valuedConflictNodes);
            SetupGroupPriorityValue();
            ConflictLineSections.IsGrouped = true;
            //组Id
            foreach (var ConflictLineSection in ConflictLineSections)
            {
                foreach (var ConflictElement in ConflictLineSection.ConflictElements)
                {
                    ConflictElement.GroupId = ConflictLineSections.GroupId;
                }
            }
        }
Пример #4
0
        public static void GetUpAndDownWidth_2(ConflictElement conflictElement, AvoidElement avoidElement, out double widthUp, out double widthDown, double height = -1)
        {
            double angleToTurn          = avoidElement.AngleToTurn;
            double miniConnectHeight    = avoidElement.ConnectHeight;
            double miniConnectWidth     = avoidElement.ConnectWidth;
            double offsetWidth          = avoidElement.OffsetWidth;
            var    elementToAvoid       = conflictElement.ConflictEle;
            var    elementToAvoidHeight = conflictElement.AvoidHeight;
            var    elementToAvoidWidth  = conflictElement.AvoidWidth;

            //对象信息反填到基础模型中
            //点位计算
            //max(垂直最短留白距离,最小斜边长度,最短切割距离)
            if (height == -1)
            {
                height = avoidElement.Height / 2 + elementToAvoidHeight / 2 + MiniSpace;
                height = Math.Max(height, MiniMepLength + miniConnectHeight * 2);//考虑构件的最小高度需求
            }
            //TODO 考虑矩形的最佳方案
            //if (avoidElement.Width!= avoidElement.Height|| elementToAvoidWidth!= elementToAvoidHeight)
            //{
            //}
            widthUp = MiniMepLength / 2 + offsetWidth;//构件最短需求
            var diameterAvoid   = Math.Max(avoidElement.Width, avoidElement.Height);
            var diameterToAvoid = Math.Max(elementToAvoidWidth, elementToAvoidHeight);
            var widthOffset     = (angleToTurn - Math.PI / 2).IsMiniValue() ? 0 : height / Math.Tan(angleToTurn);

            widthUp   = (angleToTurn - Math.PI / 2).IsMiniValue() ? widthUp : Math.Max(widthUp, (diameterAvoid / 2 + diameterToAvoid / 2 + MiniSpace) / Math.Sin(angleToTurn) - height * Math.Tan(angleToTurn)); //斜边最短需求
            widthUp   = Math.Max(widthUp, avoidElement.Width / 2 + elementToAvoidWidth / 2 + MiniSpace);                                                                                                         //直径最短需求
            widthDown = widthUp + widthOffset;                                                                                                                                                                   //水平最短距离对应的水平偏移
            //相对倾斜修正
            var curve      = (avoidElement.MEPCurve.Location as LocationCurve).Curve;
            var direction1 = (curve as Line).Direction;
            var direction2 = ((conflictElement.ConflictEle.MEPCurve.Location as LocationCurve).Curve as Line).Direction;
            var faceAngle  = direction1.AngleOnPlaneTo(direction2, new XYZ(0, 0, 1));

            widthUp   = GetFixedJumpLength(widthUp, faceAngle);
            widthDown = GetFixedJumpLength(widthDown, faceAngle);
        }
Пример #5
0
        public static double GetUpAndDownWidth(AvoidElement avoidElement, ConflictElement conflictElement, out double height, out double widthUp, out double widthDown)
        {
            XYZ    verticalDirection    = avoidElement.GetVerticalVector();
            double angleToTurn          = avoidElement.AngleToTurn;
            double miniConnectHeight    = avoidElement.ConnectHeight;
            double miniConnectWidth     = avoidElement.ConnectWidth;
            double offsetWidth          = avoidElement.OffsetWidth;
            var    curve                = (avoidElement.MEPCurve.Location as LocationCurve).Curve;
            XYZ    parallelDirection    = avoidElement.GetParallelVector();
            var    elementToAvoid       = conflictElement.ConflictEle;
            var    elementToAvoidHeight = conflictElement.AvoidHeight;
            var    elementToAvoidWidth  = conflictElement.AvoidWidth;
            XYZ    direction1           = (curve as Line).Direction;
            double faceAngle            = 0;
            XYZ    direction2           = ((elementToAvoid.MEPCurve.Location as LocationCurve).Curve as Line).Direction;//TODO 连接件的ElementToAvoid依旧需要填上 作为溯源数据源

            faceAngle = direction1.AngleOnPlaneTo(direction2, new XYZ(0, 0, 1));
            //对象信息反填到基础模型中
            //点位计算
            //max(垂直最短留白距离,最小斜边长度,最短切割距离)
            height = avoidElement.Height / 2 + elementToAvoidHeight / 2 + MiniSpace;
            height = Math.Max(height, MiniMepLength + miniConnectHeight * 2);//考虑构件的最小高度需求
            //TODO 考虑矩形的最佳方案
            //if (avoidElement.Width!= avoidElement.Height|| elementToAvoidWidth!= elementToAvoidHeight)
            //{
            //}
            widthUp = MiniMepLength / 2 + offsetWidth;
            var diameterAvoid   = Math.Max(avoidElement.Width, avoidElement.Height);
            var diameterToAvoid = Math.Max(elementToAvoidWidth, elementToAvoidHeight);
            var widthOffset     = (angleToTurn - Math.PI / 2).IsMiniValue() ? 0 : height / Math.Tan(angleToTurn);

            widthUp   = (angleToTurn - Math.PI / 2).IsMiniValue() ? widthUp : Math.Max(widthUp, (diameterAvoid / 2 + diameterToAvoid / 2 + MiniSpace) / Math.Sin(angleToTurn) - height * Math.Tan(angleToTurn)); //斜边最短需求
            widthUp   = Math.Max(widthUp, avoidElement.Width / 2 + elementToAvoidWidth / 2 + MiniSpace);                                                                                                         //直径最短需求
            widthDown = widthUp + widthOffset;
            widthUp   = GetFixedJumpLength(widthUp, faceAngle);
            widthDown = GetFixedJumpLength(widthDown, faceAngle);
            return(height);
        }
Пример #6
0
        internal ConflictElement AddConflictElement(Connector connectorToMepElement, ConflictElement srcConflictElement)
        {
            if (ConflictElements == null)
            {
                ConflictElements = new List <ConflictElement>();
            }
            ConflictElement conflictElement = null;

            if (ConnectorStart != null && ConnectorStart.Origin.VL_XYEqualTo(connectorToMepElement.Origin))
            {
                conflictElement = new ConflictElement(this, StartPoint, connectorToMepElement, srcConflictElement.ConflictEle);
            }
            else if (ConnectorEnd != null && ConnectorEnd.Origin.VL_XYEqualTo(connectorToMepElement.Origin))
            {
                conflictElement = new ConflictElement(this, EndPoint, connectorToMepElement, srcConflictElement.ConflictEle);
            }
            else
            {
                throw new NotImplementedException("错误的连接点");
            }
            ConflictElements.Add(conflictElement);
            SortConflictElements();
            return(conflictElement);
        }
Пример #7
0
        internal void SetConflictElements(List <AvoidElement> elementsToAvoid, List <ValuedConflictNode> conflictNodes)
        {
            ConflictElements = new List <ConflictElement>();
            ElementIntersectsElementFilter filter = new ElementIntersectsElementFilter(MEPCurve);
            var elementsConflicted = elementsToAvoid.Where(c => filter.PassesFilter(c.MEPCurve)).ToList();

            foreach (var elementConflicted in elementsConflicted)
            {
                var conflictLocation = GetConflictPoint(elementConflicted.MEPCurve);
                if (conflictLocation != null)
                {
                    var conflictElement = new ConflictElement(this, conflictLocation, elementConflicted);
                    ConflictElements.Add(conflictElement);
                    if (conflictNodes.FirstOrDefault(c => c.ConflictLocation.VL_XYEqualTo(conflictLocation) && (c.ValueNode1.OrientAvoidElement == this || c.ValueNode2.OrientAvoidElement == this)) == null)
                    {
                        conflictNodes.Add(new ValuedConflictNode(this, conflictLocation, elementConflicted));
                    }
                }
            }
            SortConflictElements();

            ////TEST
            //var conflictIds = string.Join(",", elementsConflicted.Select(c => c.MEPElement.Id));
        }
Пример #8
0
        }                                 //偏移高度

        internal double GetDistanceTo(ConflictElement next)
        {
            return(ConflictLocation.DistanceTo(next.ConflictLocation) - (IsConnector ? 0 : ConflictEle.Width) - (next.IsConnector ? 0 : next.ConflictEle.Width));
        }
Пример #9
0
        private static void CalculateLocations(AvoidElement avoidElement, ConflictElement conflictElement)
        {
            int    id = avoidElement.MEPCurve.Id.IntegerValue;
            double widthUp, widthDown, height;

            height = GetUpAndDownWidth(avoidElement, conflictElement, out height, out widthUp, out widthDown);
            XYZ verticalDirection = avoidElement.GetVerticalVector();
            XYZ parallelDirection = avoidElement.GetParallelVector();
            XYZ pointStart        = avoidElement.StartPoint;
            XYZ pointEnd          = avoidElement.EndPoint;
            XYZ midPoint          = conflictElement.ConflictLocation;

            if (widthUp.IsMiniValue())//偏移段为0说明偏移不足以实现,作整段偏移
            {
                conflictElement.StartSplit  = null;
                conflictElement.EndSplit    = null;
                conflictElement.MiddleStart = null;
                conflictElement.MiddleEnd   = null;
                if (!avoidElement.IsHorizontalFixed_StartPoint)
                {
                    avoidElement.StartPoint += height * verticalDirection;
                    avoidElement.IsHorizontalFixed_StartPoint = true;
                }
                if (!avoidElement.IsHorizontalFixed_EndPoint)
                {
                    avoidElement.EndPoint += height * verticalDirection;
                    avoidElement.IsHorizontalFixed_EndPoint = true;
                }
            }
            else
            {
                conflictElement.StartSplit = midPoint + parallelDirection * widthDown;
                conflictElement.EndSplit   = midPoint - parallelDirection * widthDown;
                midPoint += height * verticalDirection;
                conflictElement.MiddleStart = midPoint + parallelDirection * widthUp;
                conflictElement.MiddleEnd   = midPoint - parallelDirection * widthUp;
                //过界修正,过界则做边界的垂直偏移
                var comparer = new XYComparer();
                if (comparer.Compare(conflictElement.StartSplit, pointStart) > 0)
                {
                    if (comparer.Compare(conflictElement.MiddleStart, pointStart) > 0)
                    {
                        conflictElement.MiddleStart = null;
                    }
                    conflictElement.StartSplit = null;
                    if (!avoidElement.IsHorizontalFixed_StartPoint)
                    {
                        avoidElement.StartPoint += height * verticalDirection;
                        avoidElement.IsHorizontalFixed_StartPoint = true;
                    }
                }
                if (comparer.Compare(conflictElement.EndSplit, pointEnd) < 0)
                {
                    if (comparer.Compare(conflictElement.MiddleEnd, pointEnd) < 0)
                    {
                        conflictElement.MiddleEnd = null;
                    }
                    conflictElement.EndSplit = null;
                    if (!avoidElement.IsHorizontalFixed_EndPoint)
                    {
                        avoidElement.EndPoint += height * verticalDirection;
                        avoidElement.IsHorizontalFixed_EndPoint = true;
                    }
                }
            }
            conflictElement.OffsetHeight = height;
        }
Пример #10
0
        private void CalculateLocations(ConflictElement startConflictElement, ValueNode winner, XYZ conflictLocation, List <AvoidElement> avoidElements)
        {
            foreach (var ConflictLineSection in winner.ConflictLineSections)
            {
                var avoidElement = avoidElements.First(c => c.MEPCurve.Id == ConflictLineSection.ElementId);
                #region 各避让点避让处理
                for (int i = 0; i < ConflictLineSection.ConflictElements.Count(); i++)
                {
                    var conflictElement = ConflictLineSection.ConflictElements[i];
                    //边界计算
                    if (i > 0 && i < ConflictLineSection.ConflictElements.Count() - 1)
                    {
                        continue;
                    }
                    //区块信息整理
                    if (conflictElement.IsConnector)
                    {
                        if (avoidElement.IsStartPoint(conflictElement))
                        {
                            var       connector       = avoidElement.ConnectorStart;
                            Connector linkedConnector = connector.GetConnectedConnector();
                            if (linkedConnector != null)
                            {
                                connector.DisconnectFrom(linkedConnector);
                            }
                            ConflictLineSection.StartLinkedConnector = linkedConnector;
                            ConflictLineSection.StartPoint           = avoidElement.StartPoint;
                        }
                        if (avoidElement.IsEndPoint(conflictElement))
                        {
                            var       connector       = avoidElement.ConnectorEnd;
                            Connector linkedConnector = connector.GetConnectedConnector();
                            if (linkedConnector != null)
                            {
                                connector.DisconnectFrom(linkedConnector);
                            }
                            ConflictLineSection.EndLinkedConnector = linkedConnector;
                            ConflictLineSection.EndPoint           = avoidElement.EndPoint;
                        }
                    }
                    CalculateLocations(avoidElement, conflictElement);
                    #region old 早期代码 理由待分析
                    //CalculateLocations(avoidElement, currentConflictEle, startConflictElement.Height);
                    ////重叠关系处理
                    //if (i == 0)
                    //{
                    //    var j = 1;
                    //    while (j < ConflictLineSection.ConflictElements.Count() - 1)
                    //    {
                    //        var next = ConflictLineSection.ConflictElements[j];
                    //        if (currentConflictEle.ConflictLocation.VL_XYEqualTo(next.ConflictLocation))
                    //            CalculateLocations(avoidElement, currentConflictEle, startConflictElement.Height);
                    //        else
                    //            break;
                    //        j++;
                    //    }
                    //}
                    //if (i == ConflictLineSection.ConflictElements.Count() - 1)
                    //{
                    //    var j = ConflictLineSection.ConflictElements.Count() - 2;
                    //    while (j > 0)
                    //    {
                    //        var next = ConflictLineSection.ConflictElements[j];
                    //        if (currentConflictEle.ConflictLocation.VL_XYEqualTo(next.ConflictLocation))
                    //            CalculateLocations(avoidElement, currentConflictEle, startConflictElement.Height);
                    //        else
                    //            break;
                    //        j--;
                    //    }
                    //}
                    #endregion
                }
                #endregion
            }

            #region 避让高度一致化
            var maxOffset = winner.ConflictLineSections.Max(c => c.ConflictElements.Max(d => d.OffsetHeight));
            foreach (var ConflictLineSection in winner.ConflictLineSections)
            {
                var avoidElement      = avoidElements.First(c => c.MEPCurve.Id == ConflictLineSection.ElementId);
                XYZ verticalDirection = avoidElement.GetVerticalVector();
                for (int i = 0; i < ConflictLineSection.ConflictElements.Count(); i++)
                {
                    if (i > 0 && i < ConflictLineSection.ConflictElements.Count() - 1)
                    {
                        continue;
                    }
                    var conflictElement = ConflictLineSection.ConflictElements[i];
                    var diff            = maxOffset - conflictElement.OffsetHeight;
                    if (!diff.IsMiniValue())
                    {
                        if (conflictElement.StartSplit != null)
                        {
                            conflictElement.StartSplit += diff * verticalDirection;
                        }
                        if (conflictElement.MiddleStart != null)
                        {
                            conflictElement.MiddleStart += diff * verticalDirection;
                        }
                        if (conflictElement.MiddleEnd != null)
                        {
                            conflictElement.MiddleEnd += diff * verticalDirection;
                        }
                        if (conflictElement.EndSplit != null)
                        {
                            conflictElement.EndSplit += diff * verticalDirection;
                        }
                        if (conflictElement.StartSplit == null)
                        {
                            avoidElement.StartPoint += diff * verticalDirection;
                        }
                        if (conflictElement.EndSplit == null)
                        {
                            avoidElement.EndPoint += diff * verticalDirection;
                        }
                        conflictElement.OffsetHeight = maxOffset;
                    }
                }
            }
            winner.ConflictLineSections.OffsetHeight = maxOffset;
            #endregion
        }
Пример #11
0
        private void TopoConnector(List <ValuedConflictNode> conflictNodes, List <AvoidElement> avoidElements, Connector connector, ConflictElement conflictElement)
        {
            var connectorsToMepElement = connector.GetConnectorsToMepElement();

            foreach (var connectorToMepElement in connectorsToMepElement)
            {
                var startEle = avoidElements.FirstOrDefault(c => c.MEPCurve.Id == connectorToMepElement.Owner.Id);
                if (startEle == null)
                {
                    startEle = new AvoidElement(connectorToMepElement.Owner as MEPCurve);
                    avoidElements.Add(startEle);
                }
                var conflictEle = startEle.AddConflictElement(connectorToMepElement, conflictElement);
                SetupGroup(startEle, conflictEle, conflictNodes, avoidElements);
            }
        }
Пример #12
0
        /// <summary>
        /// 这里形成了源对象上与之碰撞的碰撞元素价值组
        /// 价值组的价值越大,自身则越应避让.
        /// 即 赢退 输不动
        /// </summary>
        /// <param name="startElement">源对象</param>
        /// <param name="conflictElement"></param>
        /// <param name="conflictNodes"></param>
        /// <param name="avoidElements"></param>
        private void SetupGroup(AvoidElement startElement, ConflictElement conflictElement, List <ValuedConflictNode> conflictNodes, List <AvoidElement> avoidElements)
        {
            var currentGroupingDistance = GroupingDistance + startElement.ConnectWidth * 2;
            XYZ direction1 = ((startElement.MEPCurve.Location as LocationCurve).Curve as Line).Direction;
            ConflictLineSection conflictLineSection = new ConflictLineSection(startElement);

            //碰撞点处理
            conflictLineSection.ConflictElements.Add(conflictElement);
            //向后 连续组团处理
            var             startIndex   = startElement.ConflictElements.IndexOf(conflictElement);
            var             currentIndex = startIndex;
            ConflictElement current      = conflictElement;
            ConflictElement next;

            for (int i = currentIndex + 1; i < startElement.ConflictElements.Count(); i++)
            {
                next = startElement.ConflictElements[i];
                if (next.IsConnector)
                {
                    break;
                }
                XYZ direction2 = ((next.ConflictEle.MEPCurve.Location as LocationCurve).Curve as Line).Direction;
                var faceAngle  = direction1.AngleOnPlaneTo(direction2, new XYZ(0, 0, 1));
                if (current.GetDistanceTo(next) > ValuedConflictNode.GetFixedJumpLength(currentGroupingDistance, faceAngle))
                {
                    break;
                }

                conflictLineSection.ConflictElements.Add(next);
                current      = next;
                currentIndex = i;
            }
            //向后 连接件处理 边界连续处理
            if (conflictElement.ConflictLocation != startElement.EndPoint && currentIndex == startElement.ConflictElements.Count() - 1)
            {
                var connector = startElement.ConnectorEnd;
                var point     = startElement.EndPoint;
                if (connector != null && current.GetDistanceTo(point) <= currentGroupingDistance)
                {
                    var continueEle = startElement.AddConflictElement(connector, conflictElement);
                    conflictLineSection.ConflictElements.Add(continueEle);
                    TopoConnector(conflictNodes, avoidElements, connector, conflictElement);
                }
            }
            //重置
            current      = conflictElement;
            currentIndex = startIndex;
            //往前 连续组团处理
            for (int i = currentIndex - 1; i >= 0; i--)
            {
                next = startElement.ConflictElements[i];
                if (next.IsConnector)
                {
                    break;
                }
                XYZ direction2 = ((next.ConflictEle.MEPCurve.Location as LocationCurve).Curve as Line).Direction;
                var faceAngle  = direction1.AngleOnPlaneTo(direction2, new XYZ(0, 0, 1));
                if (current.GetDistanceTo(next) > ValuedConflictNode.GetFixedJumpLength(currentGroupingDistance, faceAngle))
                {
                    break;
                }

                conflictLineSection.ConflictElements.Add(next);
                current      = next;
                currentIndex = i;
            }
            //往前 连接件处理
            if (conflictElement.ConflictLocation != startElement.StartPoint && currentIndex == 0)
            {
                var connector = startElement.ConnectorStart;
                var point     = startElement.StartPoint;
                if (connector != null && current.GetDistanceTo(point) <= currentGroupingDistance)
                {
                    var continueEle = startElement.AddConflictElement(connector, conflictElement);
                    conflictLineSection.ConflictElements.Add(continueEle);
                    TopoConnector(conflictNodes, avoidElements, connector, conflictElement);
                }
            }
            conflictLineSection.ConflictElements = conflictLineSection.ConflictElements.OrderByDescending(c => c.ConflictLocation, new XYZComparer()).ToList();
            ConflictLineSections.Add(conflictLineSection);
        }
Пример #13
0
 public bool IsEndPoint(ConflictElement conflictElement)
 {
     return(EndPoint.VL_XYEqualTo(conflictElement.ConflictLocation));
 }
Пример #14
0
        private static void CalculateLocations(AvoidElement avoidElement, ConflictElement conflictElement, double height = -1)
        {
            int    id = avoidElement.MEPCurve.Id.IntegerValue;
            XYZ    verticalDirection    = avoidElement.GetVerticalVector();
            double angleToTurn          = avoidElement.AngleToTurn;
            double miniConnectHeight    = avoidElement.ConnectHeight;
            double miniConnectWidth     = avoidElement.ConnectWidth;
            double offsetWidth          = avoidElement.OffsetWidth;
            var    curve                = (avoidElement.MEPCurve.Location as LocationCurve).Curve;
            var    pointStart           = avoidElement.StartPoint;
            var    pointEnd             = avoidElement.EndPoint;
            XYZ    parallelDirection    = (pointStart - pointEnd).Normalize();
            var    elementToAvoid       = conflictElement.ConflictEle;
            var    elementToAvoidHeight = conflictElement.AvoidHeight;
            var    elementToAvoidWidth  = conflictElement.AvoidWidth;
            XYZ    direction1           = (curve as Line).Direction;
            double faceAngle            = 0;
            XYZ    direction2           = ((elementToAvoid.MEPCurve.Location as LocationCurve).Curve as Line).Direction;//TODO 连接件的ElementToAvoid依旧需要填上 作为溯源数据源

            faceAngle = direction1.AngleOnPlaneTo(direction2, new XYZ(0, 0, 1));
            if (conflictElement.IsConnector)
            {
                conflictElement.ConnectorLocation = conflictElement.ConflictLocation + height * verticalDirection;
            }
            #region old
            //if (conflictElement.IsConnector)
            //{
            //    faceAngle = Math.PI / 2;//问题出在 如果连接点作为
            //    conflictElement.ConnectorLocation = conflictElement.ConflictLocation + height * verticalDirection;
            //}
            //else
            //{
            //    XYZ direction2 = ((elementToAvoid.MEPCurve.Location as LocationCurve).Curve as Line).Direction;
            //    faceAngle = direction1.AngleOnPlaneTo(direction2, new XYZ(0, 0, 1));
            //}
            #endregion
            //对象信息反填到基础模型中
            //点位计算
            var midPoint = conflictElement.ConflictLocation;
            //max(垂直最短留白距离,最小斜边长度,最短切割距离)
            if (height == -1)
            {
                height = avoidElement.Height / 2 + elementToAvoidHeight / 2 + MiniSpace;
                height = Math.Max(height, MiniMepLength + miniConnectHeight * 2);//考虑构件的最小高度需求
                conflictElement.Height = height;
            }
            //TODO 考虑矩形的最佳方案
            //if (avoidElement.Width!= avoidElement.Height|| elementToAvoidWidth!= elementToAvoidHeight)
            //{
            //}
            var widthUp         = MiniMepLength / 2 + offsetWidth;//构件最短需求
            var diameterAvoid   = Math.Max(avoidElement.Width, avoidElement.Height);
            var diameterToAvoid = Math.Max(elementToAvoidWidth, elementToAvoidHeight);
            widthUp = Math.Max(widthUp, (diameterAvoid / 2 + diameterToAvoid / 2 + MiniSpace) / Math.Sin(angleToTurn) - height * Math.Tan(angleToTurn)); //斜边最短需求
            widthUp = Math.Max(widthUp, avoidElement.Width / 2 + elementToAvoidWidth / 2 + MiniSpace);                                                   //直径最短需求
            var widthDown = widthUp + height / Math.Tan(angleToTurn);                                                                                    //水平最短距离对应的水平偏移
            widthUp   = GetFixedJumpLength(widthUp, faceAngle);
            widthDown = GetFixedJumpLength(widthDown, faceAngle);
            //double co = Math.Abs(Math.Cos(faceAngle));
            //if (!co.IsMiniValue())
            //{
            //    widthUp = widthUp / co;
            //    widthDown = widthDown / co;
            //}
            conflictElement.StartSplit = midPoint + parallelDirection * widthDown;
            conflictElement.EndSplit   = midPoint - parallelDirection * widthDown;
            midPoint += height * verticalDirection;
            conflictElement.MiddleStart = midPoint + parallelDirection * widthUp;
            conflictElement.MiddleEnd   = midPoint - parallelDirection * widthUp;
        }
Пример #15
0
 private void CalculateLocations(ConflictElement startConflictElement, ValueNode winner, XYZ conflictLocation, List <AvoidElement> avoidElements)
 {
     foreach (var ConflictLineSection in winner.ConflictLineSections)
     {
         var avoidElement = avoidElements.First(c => c.MEPCurve.Id == ConflictLineSection.ElementId);
         for (int i = 0; i < ConflictLineSection.ConflictElements.Count(); i++)
         {
             var currentConflictEle = ConflictLineSection.ConflictElements[i];
             //边界计算
             if (i == 0 || i == ConflictLineSection.ConflictElements.Count() - 1)
             {
                 //区块信息整理
                 if (currentConflictEle.IsConnector)
                 {
                     if (avoidElement.IsStartPoint(currentConflictEle))
                     {
                         var       connector       = avoidElement.ConnectorStart;
                         Connector linkedConnector = connector.GetConnectedConnector();
                         if (linkedConnector != null)
                         {
                             connector.DisconnectFrom(linkedConnector);
                         }
                         ConflictLineSection.StartLinkedConnector = linkedConnector;
                         ConflictLineSection.StartPoint           = avoidElement.StartPoint;
                     }
                     if (avoidElement.IsEndPoint(currentConflictEle))
                     {
                         var       connector       = avoidElement.ConnectorEnd;
                         Connector linkedConnector = connector.GetConnectedConnector();
                         if (linkedConnector != null)
                         {
                             connector.DisconnectFrom(linkedConnector);
                         }
                         ConflictLineSection.EndLinkedConnector = linkedConnector;
                         ConflictLineSection.EndPoint           = avoidElement.EndPoint;
                     }
                 }
                 CalculateLocations(avoidElement, currentConflictEle, startConflictElement.Height);
                 ////重叠关系处理
                 //if (i == 0)
                 //{
                 //    var j = 1;
                 //    while (j < ConflictLineSection.ConflictElements.Count() - 1)
                 //    {
                 //        var next = ConflictLineSection.ConflictElements[j];
                 //        if (currentConflictEle.ConflictLocation.VL_XYEqualTo(next.ConflictLocation))
                 //            CalculateLocations(avoidElement, currentConflictEle, startConflictElement.Height);
                 //        else
                 //            break;
                 //        j++;
                 //    }
                 //}
                 //if (i == ConflictLineSection.ConflictElements.Count() - 1)
                 //{
                 //    var j = ConflictLineSection.ConflictElements.Count() - 2;
                 //    while (j > 0)
                 //    {
                 //        var next = ConflictLineSection.ConflictElements[j];
                 //        if (currentConflictEle.ConflictLocation.VL_XYEqualTo(next.ConflictLocation))
                 //            CalculateLocations(avoidElement, currentConflictEle, startConflictElement.Height);
                 //        else
                 //            break;
                 //        j--;
                 //    }
                 //}
             }
         }
     }
 }