Exemple #1
0
 public ValuedConflictNode(AvoidElement avoidElement, XYZ conflictLocation, AvoidElement elementConflicted)
 {
     ConflictLocation = conflictLocation;
     ValueNode1       = new ValueNode(this, avoidElement);
     ValueNode2       = new ValueNode(this, elementConflicted);
 }
Exemple #2
0
        internal void Compete(List <AvoidElement> avoidElements, List <ConflictLineSections> conflictLineSections_Collection)
        {
            if (!IsGrouped || IsCompeted)
            {
                return;
            }

            bool      isWinnerSettled;
            bool      isLoserSettled;
            ValueNode winner = null;
            ValueNode loser  = null;

            if (Comparer.Compare(ValueNode1.ConflictLineSections.AvoidPriorityValue, ValueNode2.ConflictLineSections.AvoidPriorityValue) > 0)
            {
                isWinnerSettled = ValueNode1.ConflictLineSections.AvoidPriorityValue.CompeteType == CompeteType.Winner;
                if (!isWinnerSettled)
                {
                    ValueNode1.ConflictLineSections.AvoidPriorityValue.CompeteType = CompeteType.Winner;
                    winner = ValueNode1;
                }
                isLoserSettled = ValueNode2.ConflictLineSections.AvoidPriorityValue.CompeteType == CompeteType.Loser;
                if (!isLoserSettled)
                {
                    ValueNode2.ConflictLineSections.AvoidPriorityValue.CompeteType = CompeteType.Loser;
                    loser = ValueNode2;
                }
            }
            else
            {
                isLoserSettled = ValueNode1.ConflictLineSections.AvoidPriorityValue.CompeteType == CompeteType.Loser;
                if (!isLoserSettled)
                {
                    ValueNode1.ConflictLineSections.AvoidPriorityValue.CompeteType = CompeteType.Loser;
                    loser = ValueNode1;
                }
                isWinnerSettled = ValueNode2.ConflictLineSections.AvoidPriorityValue.CompeteType == CompeteType.Winner;
                if (!isWinnerSettled)
                {
                    ValueNode2.ConflictLineSections.AvoidPriorityValue.CompeteType = CompeteType.Winner;
                    winner = ValueNode2;
                }
            }
            if (!isWinnerSettled)
            {
                //避让总是以最大的避让幅度作为连续的标准
                var maxHeight = winner.ConflictLineSections.Max(c => c.ConflictElements.Max(d => d.AvoidHeight));
                var maxWidth  = winner.ConflictLineSections.Max(c => c.ConflictElements.Max(d => d.AvoidWidth));
                foreach (var ConflictLineSection in winner.ConflictLineSections)
                {
                    foreach (var ConflictElement in ConflictLineSection.ConflictElements)
                    {
                        ConflictElement.CompeteType = CompeteType.Winner;
                        ConflictElement.AvoidHeight = maxHeight;
                        ConflictElement.AvoidWidth  = maxWidth;
                    }
                }
                var conflictElement = winner.OrientAvoidElement.ConflictElements.First(c => c.ConflictLocation.VL_XYEqualTo(winner.ValuedConflictNode.ConflictLocation));
                //定位计算
                CalculateLocations(winner.OrientAvoidElement, conflictElement);
                winner.ConflictLineSections.Height = conflictElement.Height;                                                       //maxHeight;//这里应为最大避让幅度作为最终的避让距离 //但
                CalculateLocations(conflictElement, winner, ConflictLocation, avoidElements);
                if (conflictLineSections_Collection.FirstOrDefault(c => c.GroupId == winner.ConflictLineSections.GroupId) == null) //ConflictLineSections汇总
                {
                    conflictLineSections_Collection.Add(winner.ConflictLineSections);
                }
            }
            if (!isLoserSettled)
            {
                foreach (var ConflictLineSection in loser.ConflictLineSections)
                {
                    foreach (var ConflictElement in ConflictLineSection.ConflictElements)
                    {
                        ConflictElement.CompeteType = CompeteType.Loser;
                    }
                }
            }
            IsCompeted = true;
        }
Exemple #3
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--;
                 //    }
                 //}
             }
         }
     }
 }