xls 6 years ago
parent
commit
432cf69e2d

+ 7 - 0
MBI/SAGA.GplotDrawData/SAGA.GplotDrawData.csproj

@@ -79,6 +79,9 @@
     <Compile Include="DBView\ViewExtension.cs" />
     <Compile Include="DBView\VirticalSpaceGraphView.cs" />
     <Compile Include="DrawElementEdges.cs" />
+    <Compile Include="View\WinMachineRoom.xaml.cs">
+      <DependentUpon>WinMachineRoom.xaml</DependentUpon>
+    </Compile>
     <Compile Include="View\WinSystem.xaml.cs">
       <DependentUpon>WinSystem.xaml</DependentUpon>
     </Compile>
@@ -121,6 +124,10 @@
     <Compile Include="WinMachineRoomView.xaml.cs">
       <DependentUpon>WinMachineRoomView.xaml</DependentUpon>
     </Compile>
+    <Page Include="View\WinMachineRoom.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="View\WinSystem.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 48 - 0
MBI/SAGA.GplotDrawData/View/WinMachineRoom.xaml

@@ -0,0 +1,48 @@
+<windows:WinBase
+    xmlns:windows="clr-namespace:SAGA.RevitUtils.Windows;assembly=SAGA.RevitUtils"
+        x:Class="SAGA.GplotDrawData.View.WinMachineRoom"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:SAGA.GplotDrawData"
+        xmlns:drawData="clr-namespace:CEFSharpWPF;assembly=CEFSharpWPF"
+        Title="机房拓扑图" Height="450" Width="800"   WindowState="Maximized">
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="150"/>
+            <ColumnDefinition Width="*"/>
+
+        </Grid.ColumnDefinitions>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="*"/>
+            <RowDefinition Height="20"/>
+        </Grid.RowDefinitions>
+
+
+        <TreeView Name="TreeRootNode" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" SelectedItemChanged="RootNode_OnSelectedItemChanged" 
+        >
+            <TreeView.ItemContainerStyle>
+                <Style TargetType="{x:Type TreeViewItem}">
+                    <Setter Property="IsExpanded" Value="{Binding IsExpanded,Mode=TwoWay}" />
+                    <Setter Property="IsSelected" Value="{Binding IsSelected,Mode=TwoWay}" />
+                </Style>
+            </TreeView.ItemContainerStyle>
+            <TreeView.ItemTemplate>
+                <HierarchicalDataTemplate ItemsSource="{Binding Path=Nodes}">
+                    <TextBlock Name="Block" Text="{Binding Name}"></TextBlock>
+
+                    <HierarchicalDataTemplate.Triggers>
+                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=TreeViewItem},Path=IsSelected}" Value="True">
+                            <Setter TargetName="Block" Property="Background"  Value="DodgerBlue"></Setter>
+                            <Setter TargetName="Block" Property="Foreground"  Value="White"></Setter>
+                        </DataTrigger>
+                    </HierarchicalDataTemplate.Triggers>
+                </HierarchicalDataTemplate>
+
+            </TreeView.ItemTemplate>
+        </TreeView>
+
+        <drawData:UcGplotShow Grid.Row="0" Grid.Column="1" x:Name="ucShowElement"></drawData:UcGplotShow>
+    </Grid>
+</windows:WinBase>

+ 67 - 0
MBI/SAGA.GplotDrawData/View/WinMachineRoom.xaml.cs

@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Windows;
+
+using CEFSharpWPF;
+using SAGA.GplotRelationComputerManage.Draw;
+using SAGA.Models;
+using SAGA.RevitUtils.Windows;
+
+namespace SAGA.GplotDrawData.View
+{
+    /// <summary>
+    /// WinMachineRoom.xaml 的交互逻辑
+    /// </summary>
+    public partial class WinMachineRoom : WinBase
+    {
+        public WinMachineRoom()
+        {
+            InitializeComponent();
+        }
+      
+        public Func<List<DocumentNode>> LoadData;
+        private ObservableCollection<DocumentNode> DocumentNodes { get; set; }
+        protected override void OnLoaded(object sender, RoutedEventArgs e)
+        {
+            base.OnLoaded(sender, e);
+
+            DocumentNodes = new ObservableCollection<DocumentNode>(this.LoadData?.Invoke() ?? new List<DocumentNode>());
+            this.TreeRootNode.ItemsSource = DocumentNodes;
+         
+        }
+        private void SetSelectedItem(DocumentNode node)
+        {
+            node.IsSelected = true;
+            node.IsExpanded = true;
+            var parent = node.Parent;
+            while (parent != null)
+            {
+                parent.IsExpanded = true;
+                parent = parent.Parent;
+            }
+
+            RootNode_OnSelectedItemChanged(null, null);
+        }
+
+        #region 事件相关
+        private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
+        {
+            if (TreeRootNode.SelectedItem is DocumentNode ln)
+            {
+                Draw(ln);
+            }
+        }
+        #endregion
+        private void Draw(DocumentNode docNode)
+        {
+            if (docNode?.LinkDocument == null)
+                return;
+            GplotDocument document = docNode.LinkDocument;
+            RoomGraphView view = new RoomGraphView();
+            var db = view.CreateDb(document);
+            ConstData.ResponseData = db.CreateJObjectGroup();
+            ucShowElement.Show(WebGplotSettings.GplotUrl);
+        }
+    }
+}

+ 27 - 26
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemParse.cs

@@ -60,25 +60,25 @@ namespace SAGA.GplotRelationComputerManage
             LoadEquipmentItem(edges);
             //确定边类型
             LoadEdgeSystem(edges);
-            var outPutEdges = edges.GetAvailableEdges(null);
-            var outPutVertexes = edges.GetAvailableVertexes(null);
-             StringBuilder builders = new StringBuilder();
-            foreach (var elementsVertex in outPutVertexes)
-            {
+            //var outPutEdges = edges.GetAvailableEdges(null);
+            //var outPutVertexes = edges.GetAvailableVertexes(null);
+            // StringBuilder builders = new StringBuilder();
+            //foreach (var elementsVertex in outPutVertexes)
+            //{
               
-                builders.Append("Id:" + elementsVertex.Id);
-                builders.Append("RefIds:" +string.Join(",",elementsVertex.RefData.Select(e=>e.Id.ToString())) );
-                builders.AppendLine();
-            }
-            foreach (var elementsEdge in outPutEdges)
-            {
-                  builders.Append("Id:" + elementsEdge.Id);
-                 builders.Append("StartId:" + elementsEdge.RealStart.Id);
-                 builders.Append("EndId:" + elementsEdge.RealEnd.Id);
-                 builders.AppendLine();
-            }
+            //    builders.Append("Id:" + elementsVertex.Id);
+            //    builders.Append("RefIds:" +string.Join(",",elementsVertex.RefData.Select(e=>e.Id.ToString())) );
+            //    builders.AppendLine();
+            //}
+            //foreach (var elementsEdge in outPutEdges)
+            //{
+            //      builders.Append("Id:" + elementsEdge.Id);
+            //     builders.Append("StartId:" + elementsEdge.RealStart.Id);
+            //     builders.Append("EndId:" + elementsEdge.RealEnd.Id);
+            //     builders.AppendLine();
+            //}
 
-            File.WriteAllText(@"d:\test.txt", builders.ToString());
+            //File.WriteAllText(@"d:\test.txt", builders.ToString());
             #endregion
             #region 重复迭代进行串并联操作
             edges = ElementEdgesArray.ArrangeHandle(edges);
@@ -404,13 +404,15 @@ namespace SAGA.GplotRelationComputerManage
                 //获取边系统类型
                 originEdge.SystemName = (refElements.FirstOrDefault(e => e is MEPCurve) as MEPCurve)?.GetSystemTypeName();
                 //根据系统类型和特殊设备确定旁通和补水;未完,待续
-                originEdge.EdgeCategory = Setting.GplotOptions.GetCategory(originEdge.SystemName);
+                var systemItem = Setting.RelationTypeShell.GetFirstMatchSystem(originEdge.SystemName);
+                originEdge.EdgeCategory = systemItem.ContainEdgeTypes.FirstOrDefault();// Setting.GplotOptions.GetCategory(originEdge.SystemName);
+                originEdge.FlowType = systemItem.FlowType == FlowType.In ? 2 : 1;
             }
             #endregion
             #region 方向处理
 
             var vertexes = edgesArray.GetAvailableVertexes(null)
-                .Where(v => v.GetEquipment()?.Name == Setting.GplotOptions.ValveName);
+                .Where(v => SystemCalcUtil.IsStartValveName(v.GetEquipment()?.Name));
             if (!vertexes.Any())
                 return;
             //优先找-1边的类型,外挂顺其自然;
@@ -430,8 +432,7 @@ namespace SAGA.GplotRelationComputerManage
                     {
                         continue;
                     }
-
-                    if (tempEdges.Any(e => Setting.GplotOptions.GetFlowByCategory(e.EdgeCategory) == -1))
+                    if (tempEdges.Any(e => e.FlowType == 2))
                     {                  
                             item.Name = "出口"+item.Id;
                     }
@@ -446,21 +447,21 @@ namespace SAGA.GplotRelationComputerManage
             #endregion
 
             #region 找到起始点
-              int flag = -1;
+              int flag = 2;
             var useVertex = refEdges.FirstOrDefault(c =>
-                c.Item2.Any(e => Setting.GplotOptions.GetFlowByCategory(e.EdgeCategory) == flag));
+                c.Item2.Any(e =>e.FlowType == flag));
             
             if (useVertex == null)
             {
                 flag = 1;
                 useVertex = refEdges.FirstOrDefault(c =>
-                c.Item2.Any(e => Setting.GplotOptions.GetFlowByCategory(e.EdgeCategory) == flag));
+                c.Item2.Any(e => e.FlowType == flag));
             }
 
             if (useVertex == null)
             {
                 useVertex = refEdges.FirstOrDefault();
-                flag = -1;
+                flag =1;
             }
 
             #endregion
@@ -486,7 +487,7 @@ namespace SAGA.GplotRelationComputerManage
                         }
 
                         handledIds.Add(elementsEdge.Id);
-                        if (flag == -1)
+                        if (flag == 1)
                         {
                             if (elementsEdge.RealStart.Id== startId)
                             {

+ 31 - 24
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemParseSetting.cs

@@ -7,6 +7,8 @@ using System.Threading.Tasks;
 using SAGA.RevitUtils.Extends;
 using SAGA.RevitUtils.MEP;
 using SAGA.RevitUtils;
+using SAGA.MBI.Tools;
+using System.Text.RegularExpressions;
 
 namespace SAGA.GplotRelationComputerManage
 {
@@ -17,12 +19,25 @@ namespace SAGA.GplotRelationComputerManage
     {
         public SystemParseSetting(GplotOptions options)
         {
-            GplotOptions = options;
+            //GplotOptions = options;
         }
+        public SystemParseSetting(RelationTypeShell relationShell)
+        {
+            RelationTypeShell = relationShell;
+            Domain = relationShell.IsPipeSystem() ? Domain.DomainPiping : Domain.DomainHvac;
+        }
+        ///// <summary>
+        ///// 图相关设置
+        ///// </summary>
+        //public GplotOptions GplotOptions { get; set; }
         /// <summary>
-        /// 图相关设置
+        /// 关系类型相关
         /// </summary>
-        public GplotOptions GplotOptions { get; set; }
+        public RelationTypeShell RelationTypeShell { get;private set; }
+        /// <summary>
+        /// 使用域枚举
+        /// </summary>
+        public Domain Domain { get;private set; }
         #region 设置相关信息
         /*
          * 1、确定边界:
@@ -39,7 +54,7 @@ namespace SAGA.GplotRelationComputerManage
         /// <returns></returns>
         public bool IsForkNode(Element element)
         {
-            Domain domain = GplotOptions.GplotType.GetDomain();
+            Domain domain = Domain;
             var connectors = element.GetConnectors(domain);
             return connectors.Count > 2;
         }
@@ -47,7 +62,7 @@ namespace SAGA.GplotRelationComputerManage
         public List<JoinItem> GetJoinItems(Element element,List<int> usedIds)
         {
             List<JoinItem> joinItems = new List<JoinItem>();
-              Domain domain = GplotOptions.GplotType.GetDomain();
+              Domain domain = Domain;
             var connectors = element.GetConnectors(domain);
             foreach (var connector in connectors)
             {
@@ -92,20 +107,7 @@ namespace SAGA.GplotRelationComputerManage
             {
                 return false;
             }
-            List<BuiltInCategory> categories = new List<BuiltInCategory>();
-            categories.Add(BuiltInCategory.OST_PipeAccessory);
-            categories.Add(BuiltInCategory.OST_PipeFitting);
-            categories.Add(BuiltInCategory.OST_DuctAccessory);
-            categories.Add(BuiltInCategory.OST_DuctFitting);
-            if (categories.Any(c => element.Category.Id.IntegerValue == (int)c))
-            {
-                return false;
-            }
-          
-            string namePrefix = element.GetFamily()?.Name??string.Empty;
-            var array = namePrefix.Split('-');
-            bool checkName = array.Any() && array[0].Count() == 4 && array[0].All(c => char.IsLetter(c));          
-            return checkName;
+            return MBIInfoUtil.IsEquipment(element);         
         }
         /// <summary>
         /// 无用边,节点可连通
@@ -139,12 +141,12 @@ namespace SAGA.GplotRelationComputerManage
                 if (owner is MEPCurve mepCurve)
                 {
                     string typeName = mepCurve.GetSystemTypeName();
-                    result = !GplotOptions.MatchSystemType(typeName);
+                    result = !RelationTypeShell.IsMatchSystem(typeName);
                     break;
                 }
-                if (owner is FamilyInstance && (owner as FamilyInstance).GetFamily().Name == GplotOptions.ValveName)
+                if (SystemCalcUtil.IsStartValve(owner))
                 {
-                    result = connector.Description != GplotOptions.ValveConnectorDescription;
+                    result = Regex.IsMatch(connector.Description, AppSetting.EndFlag);// connector.Description != GplotOptions.ValveConnectorDescription;
                     break;
                 } 
                 #endregion
@@ -154,7 +156,7 @@ namespace SAGA.GplotRelationComputerManage
                     if (mepCurves.Any())
                     {
                         string typeName = (mepCurves[0] as MEPCurve).GetSystemTypeName();
-                        result = !GplotOptions.MatchSystemType(typeName);
+                        result = !RelationTypeShell.IsMatchSystem(typeName);// !GplotOptions.MatchSystemType(typeName);
                     }
 
                     break;
@@ -170,8 +172,13 @@ namespace SAGA.GplotRelationComputerManage
         /// <returns></returns>
         public bool IsSpecialValve(Element element)
         {
-            return (element is FamilyInstance && (element as FamilyInstance).GetFamily().Name == GplotOptions.ValveName);
+            if(element is FamilyInstance fi)
+            {
+                var name = fi.GetFamily().Name;
 
+               return Regex.IsMatch(name, AppSetting.FamilyStartFlag);
+            }
+            return false;
         } 
         #endregion
     }

+ 27 - 1
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/SystemCalcUtil.cs

@@ -41,7 +41,33 @@ namespace SAGA.GplotRelationComputerManage
            }
            return (element.GetParameterString(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS)??string.Empty).StartsWith(AppSetting.StartFlag);
         }
-
+        /// <summary>
+        /// 判定元素是否是特殊阀门
+        /// </summary>
+        /// <param name="element"></param>
+        /// <returns></returns>
+        public static bool IsStartValve(Element element)
+        {
+            if (element is FamilyInstance)
+            {
+                var name = element.GetFamily().Name;
+                return Regex.IsMatch(name, AppSetting.FamilyStartFlag);
+            }
+            return false;
+        }
+        /// <summary>
+        /// 判定元素是否是特殊阀门
+        /// </summary>
+        /// <param name="name"></param>
+        /// <returns></returns>
+        public static bool IsStartValveName(string name)
+        {
+            if (!string.IsNullOrWhiteSpace(name))
+            {
+                return Regex.IsMatch(name, AppSetting.FamilyStartFlag);
+            }
+            return false;
+        }
         /// <summary>
         /// 创建房间缓冲集合
         /// </summary>

+ 20 - 0
MBI/SAGA.GplotRelationComputerManage/SystemRelation/FloorSystemItem.cs

@@ -421,5 +421,25 @@ namespace SAGA.GplotRelationComputerManage
 
         }
         #endregion
+
+        #region 解析机房数据
+        private void ParseMachineRoomData()
+        {
+            //GplotOptions options = new GplotOptions();
+            //options.BaseOnDefinition(Definition);
+            //SystemParse parse = new SystemParse(new SystemParseSetting(options));
+            //StartElementsManager startManager = new StartElementsManager(options);
+            ////所有项目中所有文档
+            //List<Element> startElements = new List<Element>();
+            //startElements.AddRange(startManager.GetStartElements(Document));
+            //var arrays = parse.Execute(startElements);
+            ////arrays.ForEach(a => parse.LoadEquipmentItem(a));
+            ////去除不包含真实设备的拓扑
+            //arrays.RemoveAll(c => c.GetAvailableVertexes(null).All(v => !v.IsRealEquipment()));
+
+            ////GplotParseData data = new GplotParseData();
+            //data.OriginalData = arrays;
+        }
+        #endregion
     }
 }

+ 5 - 0
MBI/SAGA.RevitUtils/Data/ElementsEdge.cs

@@ -85,6 +85,11 @@ namespace SAGA.RevitUtils
         /// 边类别
         /// </summary>
         public string EdgeCategory { get; set; } 
+
+        /// <summary>
+        /// flowType[流出为1,流入为2]
+        /// </summary>
+        public int FlowType { get; set; }
         #endregion
         #region 真实点维护