|
@@ -78,8 +78,6 @@ namespace SAGA.GplotManage
|
|
var verticalSets = relationData.VerticalRelationRecords;
|
|
var verticalSets = relationData.VerticalRelationRecords;
|
|
var cacheFloorDatas = new List<BinaryRelationItem>(floorRelations);
|
|
var cacheFloorDatas = new List<BinaryRelationItem>(floorRelations);
|
|
List < StringFlag <VerticalRelationRecord>> verticalNodes = new List<StringFlag<VerticalRelationRecord>>();
|
|
List < StringFlag <VerticalRelationRecord>> verticalNodes = new List<StringFlag<VerticalRelationRecord>>();
|
|
- Dictionary<string,EquipmentNode> nodes =new Dictionary<string, EquipmentNode>();
|
|
|
|
- List<EAEdge<string>> edges = new List<EAEdge<string>>();
|
|
|
|
#region 初始化立管节点
|
|
#region 初始化立管节点
|
|
foreach (var verticalRelationRecord in verticalSets)
|
|
foreach (var verticalRelationRecord in verticalSets)
|
|
{
|
|
{
|
|
@@ -89,14 +87,102 @@ namespace SAGA.GplotManage
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 构建端部临时边集
|
|
#region 构建端部临时边集
|
|
- for (int i = cacheFloorDatas.Count - 1; i >= 0; i--)
|
|
|
|
|
|
+ var endGraph = CreateGraph(verticalNodes, cacheFloorDatas);
|
|
|
|
+ #endregion
|
|
|
|
+ var roomItems = machineRoomData.SelectMany(c => c.RelationItems).ToList();
|
|
|
|
+ var sourceGraph = CreateGraph(verticalNodes, roomItems);
|
|
|
|
+ //连接类型,以机房端类型为基准
|
|
|
|
+ #region 机房和平面关联
|
|
|
|
+ foreach (var verticalNode in verticalNodes)
|
|
|
|
+ {
|
|
|
|
+ var startNode = sourceGraph.FindVertex(verticalNode.Flag);
|
|
|
|
+ #region 源路径
|
|
|
|
+ var sourcePathNodes = sourceGraph.GetPaths2(startNode, end =>
|
|
|
|
+ {
|
|
|
|
+ if (end.Data is EquipmentNode eqNode)
|
|
|
|
+ {
|
|
|
|
+ return eqNode.IsRealEquipment;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ });
|
|
|
|
+ #endregion
|
|
|
|
+ #region 端路径
|
|
|
|
+ var endPathNodes = endGraph.GetPaths2(startNode, end =>
|
|
|
|
+ {
|
|
|
|
+ if (end.Data is EquipmentNode eqNode)
|
|
|
|
+ {
|
|
|
|
+ return eqNode.IsRealEquipment;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ });
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ List<EquipmentNode> endNodes = new List<EquipmentNode>();
|
|
|
|
+ foreach (var endPathNode in endPathNodes)
|
|
|
|
+ {
|
|
|
|
+ var useEdge = endPathNode.LastOrDefault();
|
|
|
|
+ if (useEdge == null)
|
|
|
|
+ continue;
|
|
|
|
+ if (useEdge.NextNode.Data is EquipmentNode node)
|
|
|
|
+ {
|
|
|
|
+ endNodes.Add(node);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ foreach (var sourcePathNode in sourcePathNodes)
|
|
|
|
+ {
|
|
|
|
+ var useEdge = sourcePathNode.LastOrDefault();
|
|
|
|
+ if (useEdge == null)
|
|
|
|
+ continue;
|
|
|
|
+ EquipmentNode useNode = null;
|
|
|
|
+ if (useEdge.NextNode.Data is EquipmentNode node)
|
|
|
|
+ {
|
|
|
|
+ useNode=node;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ foreach (var equipmentNode in endNodes)
|
|
|
|
+ {
|
|
|
|
+ BinaryRelationItem item = new BinaryRelationItem();
|
|
|
|
+ item.RelationType = (useEdge.Path.Data as string) ?? string.Empty;
|
|
|
|
+ if (useEdge.Path.ContainVertex(useEdge.NextNode.Id) == 0)
|
|
|
|
+ {
|
|
|
|
+ item.From = useNode;
|
|
|
|
+ item.To = equipmentNode;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ item.From = equipmentNode;
|
|
|
|
+ item.To = useNode;
|
|
|
|
+ }
|
|
|
|
+ result.Add(CreateRelationData(item));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private static SimpleObjectGraph CreateGraph(List<StringFlag<VerticalRelationRecord>> verticalNodes, List<BinaryRelationItem> sourceRelations)
|
|
|
|
+ {
|
|
|
|
+ SimpleObjectGraph graph = new SimpleObjectGraph();
|
|
|
|
+ #region 构建临时边集
|
|
|
|
+ for (int i = sourceRelations.Count - 1; i >= 0; i--)
|
|
{
|
|
{
|
|
- var currentRecord = cacheFloorDatas[i];
|
|
|
|
- //找到立管,创建立管节点。不包含立管,直接将关联关系加入
|
|
|
|
|
|
+ var currentRecord = sourceRelations[i];
|
|
var startId = currentRecord.From.BimId;
|
|
var startId = currentRecord.From.BimId;
|
|
var endId = currentRecord.To.BimId;
|
|
var endId = currentRecord.To.BimId;
|
|
- nodes[startId] = currentRecord.From;
|
|
|
|
- nodes[endId] = currentRecord.To;
|
|
|
|
|
|
+ graph.AddVertex(new SimpleVertex<object>(currentRecord.From) {Id = startId});
|
|
|
|
+ graph.AddVertex(new SimpleVertex<object>(currentRecord.To) { Id = endId });
|
|
string replaceStart = null;
|
|
string replaceStart = null;
|
|
string replaceEnd = null;
|
|
string replaceEnd = null;
|
|
for (int j = 0; j < verticalNodes.Count; j++)
|
|
for (int j = 0; j < verticalNodes.Count; j++)
|
|
@@ -104,167 +190,28 @@ namespace SAGA.GplotManage
|
|
if (replaceStart != null && replaceEnd != null)
|
|
if (replaceStart != null && replaceEnd != null)
|
|
break;
|
|
break;
|
|
var currentVertical = verticalNodes[i];
|
|
var currentVertical = verticalNodes[i];
|
|
-
|
|
|
|
if (currentVertical.Instance.RelationItems.Contains(startId))
|
|
if (currentVertical.Instance.RelationItems.Contains(startId))
|
|
{
|
|
{
|
|
- replaceStart = currentVertical.Flag;
|
|
|
|
-
|
|
|
|
|
|
+ replaceStart = currentVertical.Flag;
|
|
}
|
|
}
|
|
if (currentVertical.Instance.RelationItems.Contains(endId))
|
|
if (currentVertical.Instance.RelationItems.Contains(endId))
|
|
{
|
|
{
|
|
replaceEnd = currentVertical.Flag;
|
|
replaceEnd = currentVertical.Flag;
|
|
}
|
|
}
|
|
|
|
+ graph.AddVertex(new SimpleVertex<object>(currentVertical.Instance) { Id = currentVertical.Flag });
|
|
}
|
|
}
|
|
-
|
|
|
|
replaceStart = replaceStart ?? startId;
|
|
replaceStart = replaceStart ?? startId;
|
|
replaceEnd = replaceEnd ?? startId;
|
|
replaceEnd = replaceEnd ?? startId;
|
|
if (!string.IsNullOrWhiteSpace(replaceStart) && !string.IsNullOrWhiteSpace(replaceEnd))
|
|
if (!string.IsNullOrWhiteSpace(replaceStart) && !string.IsNullOrWhiteSpace(replaceEnd))
|
|
{
|
|
{
|
|
- EAEdge<string> edge = new EAEdge<string>();
|
|
|
|
- edge.StartVertex = replaceStart;
|
|
|
|
- edge.EndVertex = replaceEnd;
|
|
|
|
- edges.Add(edge);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- #endregion
|
|
|
|
-
|
|
|
|
- foreach (var binaryRelationItem in roomRelations)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //连接类型,以机房端类型为基准
|
|
|
|
- #region 机房和平面关联
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * 前提不是全设备
|
|
|
|
- * 产生关系方式 源--阀门--立管a-立管b--端,源--阀门--端;
|
|
|
|
- * 连接类型和连接方向,以源端的结果为准
|
|
|
|
- */
|
|
|
|
- foreach (var roomRelation in roomRelations)
|
|
|
|
- {
|
|
|
|
- EquipmentNode equipmentNode, linkNode;
|
|
|
|
- var systemName = roomRelation.RelationType;
|
|
|
|
-
|
|
|
|
- #region 源
|
|
|
|
-
|
|
|
|
- if (!roomRelation.From.IsRealEquipment && !roomRelation.To.IsRealEquipment)
|
|
|
|
- {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (roomRelation.From.IsRealEquipment)
|
|
|
|
- {
|
|
|
|
- equipmentNode = roomRelation.From;
|
|
|
|
- linkNode = roomRelation.To;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- equipmentNode = roomRelation.To;
|
|
|
|
- linkNode = roomRelation.From;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- #endregion
|
|
|
|
-
|
|
|
|
- #region 端
|
|
|
|
-
|
|
|
|
- foreach (var endRelation in floorRelations)
|
|
|
|
- {
|
|
|
|
- var mathFlag = endRelation.TryGetNode(n => n.BimId == linkNode.BimId, out EquipmentNode refNode);
|
|
|
|
- if (mathFlag > -1)
|
|
|
|
- {
|
|
|
|
- var anotherNode = endRelation.GetAnotherNode(n => n.BimId == refNode.BimId);
|
|
|
|
- if (anotherNode.IsRealEquipment)
|
|
|
|
- {
|
|
|
|
- //第三种情况
|
|
|
|
- BinaryRelationItem newRelationItem = new BinaryRelationItem();
|
|
|
|
- newRelationItem.From = equipmentNode;
|
|
|
|
- newRelationItem.To = anotherNode;
|
|
|
|
- newRelationItem.RelationType = systemName;
|
|
|
|
- result.Add(CreateRelationData(newRelationItem));
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- var verticalSet = verticalSets.FirstOrDefault(s =>
|
|
|
|
- s.RelationItems.Any(item => item == anotherNode.BimId));
|
|
|
|
- if (verticalSet == null)
|
|
|
|
- continue;
|
|
|
|
- var verticalIds = new List<string>(verticalSet.RelationItems);
|
|
|
|
- foreach (var verticalId in verticalIds)
|
|
|
|
- {
|
|
|
|
- bool findV = false;
|
|
|
|
-
|
|
|
|
- #region 立管找端
|
|
|
|
-
|
|
|
|
- foreach (var vEndRelation in floorRelations)
|
|
|
|
- {
|
|
|
|
- var vAnother = vEndRelation.GetAnotherNode(n => n.BimId == verticalId);
|
|
|
|
- if (vAnother == null || !vAnother.IsRealEquipment)
|
|
|
|
- {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //第二种情况
|
|
|
|
- BinaryRelationItem newRelationItem = new BinaryRelationItem();
|
|
|
|
- newRelationItem.From = equipmentNode;
|
|
|
|
- newRelationItem.To = vAnother;
|
|
|
|
- newRelationItem.RelationType = systemName;
|
|
|
|
- result.Add(CreateRelationData(newRelationItem));
|
|
|
|
- findV = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- #endregion
|
|
|
|
-
|
|
|
|
- if (findV)
|
|
|
|
- {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- #region 立管找源
|
|
|
|
-
|
|
|
|
- foreach (var vSourceRelation in roomRelations)
|
|
|
|
- {
|
|
|
|
- var vAnother = vSourceRelation.GetAnotherNode(n => n.BimId == verticalId);
|
|
|
|
- if (vAnother == null)
|
|
|
|
- {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- #region 源找端
|
|
|
|
-
|
|
|
|
- foreach (var floorRelation in floorRelations)
|
|
|
|
- {
|
|
|
|
- var sa = floorRelation.GetAnotherNode(n => n.BimId == vAnother.BimId);
|
|
|
|
- if (sa == null || !sa.IsRealEquipment)
|
|
|
|
- {
|
|
|
|
- //第一种情况
|
|
|
|
- BinaryRelationItem newRelationItem = new BinaryRelationItem();
|
|
|
|
- newRelationItem.From = equipmentNode;
|
|
|
|
- newRelationItem.To = sa;
|
|
|
|
- newRelationItem.RelationType = systemName;
|
|
|
|
- result.Add(CreateRelationData(newRelationItem));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- #endregion
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- #endregion
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- #endregion
|
|
|
|
|
|
+ SimpleEdge<object> edge = new SimpleEdge<object>(replaceStart, replaceEnd);
|
|
|
|
+ edge.Data = currentRecord.RelationType;
|
|
|
|
+ graph.AddEdge(edge);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
- return result;
|
|
|
|
-
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
+ return graph;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 创建上传关系数据
|
|
/// 创建上传关系数据
|
|
/// </summary>
|
|
/// </summary>
|