|
@@ -8,9 +8,12 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
+using System.Windows.Media.Media3D;
|
|
|
using Autodesk.Revit.DB;
|
|
|
using Autodesk.Revit.DB.Mechanical;
|
|
|
using Autodesk.Revit.DB.Plumbing;
|
|
|
+using SAGA.Models;
|
|
|
+using SAGA.Models.Graphs;
|
|
|
using SAGA.RevitUtils;
|
|
|
using SAGA.RevitUtils.Extends;
|
|
|
using SAGA.RevitUtils.MEP;
|
|
@@ -300,15 +303,30 @@ namespace SAGA.GplotRelationComputerManage
|
|
|
#endregion
|
|
|
|
|
|
#region 创建关系数据相关
|
|
|
- public static List<EquipmentNode> CreateRelation(ElementTreeNode etn)
|
|
|
+ public static List<BinaryRelationItem> CreateRelation(ElementTreeNode etn)
|
|
|
{
|
|
|
+ List<BinaryRelationItem> result = new List<BinaryRelationItem>();
|
|
|
#region 描述
|
|
|
/*
|
|
|
- * 1、将树形结构初步处理,修剪成存留设备之间的关系
|
|
|
+ * 1、将树形结构初步处理,修剪成存留设备之间的关系;
|
|
|
+ * 2、处理成二维关系
|
|
|
*/
|
|
|
#endregion
|
|
|
-
|
|
|
- return ConvertEquipmentNodes(etn);
|
|
|
+ var equipmentNodes= ConvertEquipmentNodes(etn);
|
|
|
+ var loopNodes = new List<EquipmentNode>(equipmentNodes);
|
|
|
+ for (int i = 0; i < loopNodes.Count; i++)
|
|
|
+ {
|
|
|
+ var currentNode = loopNodes[i];
|
|
|
+ foreach (var childNode in currentNode.Nodes)
|
|
|
+ {
|
|
|
+ BinaryRelationItem relation = new BinaryRelationItem();
|
|
|
+ relation.From = currentNode.CloneCurrentNode();
|
|
|
+ relation.To = childNode.CloneCurrentNode();
|
|
|
+ result.Add(relation);
|
|
|
+ loopNodes.Add(childNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -319,14 +337,22 @@ namespace SAGA.GplotRelationComputerManage
|
|
|
private static List<EquipmentNode> ConvertEquipmentNodes(ElementTreeNode etn)
|
|
|
{
|
|
|
List<EquipmentNode> nodes = new List<EquipmentNode>();
|
|
|
- if (TryGetNode(etn.Current,out EquipmentNode outNode))
|
|
|
- {
|
|
|
- nodes.Add(outNode);
|
|
|
- return nodes;
|
|
|
- }
|
|
|
- foreach (var elementTreeNode in etn.Nodes)
|
|
|
+ List<ElementTreeNode> loopNodes = new List<ElementTreeNode>(){ etn };
|
|
|
+ for (int i = 0; i < loopNodes.Count; i++)
|
|
|
{
|
|
|
- nodes.AddRange(ConvertEquipmentNodes(elementTreeNode));
|
|
|
+ var currentNode = loopNodes[i];
|
|
|
+ if (TryGetNode(currentNode.Current, out EquipmentNode outNode))
|
|
|
+ {
|
|
|
+ foreach (var currentNodeNode in currentNode.Nodes)
|
|
|
+ {
|
|
|
+ outNode.AddChildren(ConvertEquipmentNodes(currentNodeNode));
|
|
|
+ }
|
|
|
+ nodes.Add(outNode);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ loopNodes.AddRange(currentNode.Nodes);
|
|
|
+ }
|
|
|
}
|
|
|
return nodes;
|
|
|
}
|
|
@@ -340,8 +366,7 @@ namespace SAGA.GplotRelationComputerManage
|
|
|
{
|
|
|
bool flag = false;
|
|
|
EquipmentNode node = new EquipmentNode();
|
|
|
- node.RevitId = element.Id.IntegerValue;
|
|
|
- node.BimId = element.GetBimId();
|
|
|
+
|
|
|
if (element is Space space)
|
|
|
{
|
|
|
node.Category = PointItemType.Space.ToString();
|
|
@@ -363,8 +388,120 @@ namespace SAGA.GplotRelationComputerManage
|
|
|
}
|
|
|
flag = !string.IsNullOrEmpty(node.Category);
|
|
|
outNode = flag ? node : null;
|
|
|
+ #region 确定返回之后进行后初始化处理
|
|
|
+ if (outNode != null)
|
|
|
+ {
|
|
|
+ outNode.RevitId = element.Id.IntegerValue;
|
|
|
+ outNode.BimId = element.GetBimId();
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
return flag;
|
|
|
}
|
|
|
#endregion
|
|
|
+
|
|
|
+ #region 创建立面绘图和关系数据
|
|
|
+ /// <summary>
|
|
|
+ /// 计算立面数据
|
|
|
+ /// </summary>
|
|
|
+ public static void ComputerVerticalData(List<VerticalPipe> pipeDatas, List<LevelData> levelDatas)
|
|
|
+ {
|
|
|
+
|
|
|
+ List<VerticalDrawRecord> drawRecords = new List<VerticalDrawRecord>();
|
|
|
+ List<VerticalRelationRecord> relationRecords = new List<VerticalRelationRecord>();
|
|
|
+ #region 标高绘图数据整理
|
|
|
+ List<VFloor> floors = new List<VFloor>();
|
|
|
+ for (int i = 0; i < levelDatas.Count; i++)
|
|
|
+ {
|
|
|
+ var tempFloor = new VFloor();
|
|
|
+ tempFloor.Name = levelDatas[i].Name;
|
|
|
+ if (tempFloor.Name == "F1")
|
|
|
+ {
|
|
|
+ tempFloor.ValueDescription = "G";
|
|
|
+ }
|
|
|
+ tempFloor.Index = i;
|
|
|
+ tempFloor.FloorId = i.ToString();
|
|
|
+ tempFloor.LinkId = levelDatas[i].Id;
|
|
|
+ floors.Add(tempFloor);
|
|
|
+
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+ #region 立管或相当于立管的空间处理
|
|
|
+ /*
|
|
|
+ * 按系统分组,[一个空间会不会对应多个系统]
|
|
|
+ */
|
|
|
+ var comparer = new VpComparer();
|
|
|
+
|
|
|
+ int groupId = 0;
|
|
|
+ //按系统分组
|
|
|
+ var goupSystems = pipeDatas.GroupBy(p => p.PipeSytemType);
|
|
|
+ foreach (var groupSystem in goupSystems)
|
|
|
+ {
|
|
|
+ //按坐标分组
|
|
|
+ foreach (var groupPosition in groupSystem.GroupBy(p=>p.DownPoint3D, comparer))
|
|
|
+ {
|
|
|
+ var currentGroupdId = groupId + 1;
|
|
|
+ SetRelationItem set = new SetRelationItem();
|
|
|
+ #region 处理绘图数据
|
|
|
+ foreach (var groupFloor in groupPosition.GroupBy(p => p.LevelName))
|
|
|
+ {
|
|
|
+ var verData = groupFloor.FirstOrDefault();
|
|
|
+ string floorId = floors.FirstOrDefault(c => c.Name == groupFloor.Key)?.FloorId;
|
|
|
+ #region 生成存储核心数据
|
|
|
+ VPipe pipe = new VPipe();
|
|
|
+ pipe.LinkId = verData.Id;
|
|
|
+ pipe.Name = string.Join(",", groupFloor.Select(v => v.Display));//verData.Display;
|
|
|
+ pipe.Tip = verData.DisplayTip;
|
|
|
+ pipe.PipeSystemType = verData.PipeSytemType;
|
|
|
+ pipe.FloorId = floorId;
|
|
|
+ #endregion
|
|
|
+ VerticalDrawRecord drawRecord = new VerticalDrawRecord();
|
|
|
+ drawRecord.GroupId = currentGroupdId.ToString();
|
|
|
+ drawRecord.RefPipe = pipe;
|
|
|
+ drawRecord.SystemName = groupSystem.Key;
|
|
|
+ drawRecords.Add(drawRecord);
|
|
|
+ set.AddRange(groupFloor.Select(v => string.Format("{0}:{1}", floorId, v.Id)));
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 处理关系数据
|
|
|
+
|
|
|
+ VerticalRelationRecord relationRecord = new VerticalRelationRecord();
|
|
|
+ relationRecord.SystemName = groupSystem.Key;
|
|
|
+ relationRecord.RelationItems = set;
|
|
|
+ relationRecords.Add(relationRecord);
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 点位置比较相关
|
|
|
+ /// </summary>
|
|
|
+ public class VpComparer : IEqualityComparer<Point3D>
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 立管左右错开小于2Cm
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="x"></param>
|
|
|
+ /// <param name="y"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public bool Equals(Point3D x, Point3D y)
|
|
|
+ {//数据为英寸
|
|
|
+ var diff = 2 * 10d / 304.8;
|
|
|
+ return Math.Abs(x.X - y.X) <= diff && Math.Abs(x.Y - y.Y) <= diff;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int GetHashCode(Point3D obj)
|
|
|
+ {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
}
|
|
|
}
|