|
@@ -101,7 +101,16 @@ namespace SAGA.GplotRelationComputerManage
|
|
*/
|
|
*/
|
|
#endregion
|
|
#endregion
|
|
AttachVertexInfo(graph);
|
|
AttachVertexInfo(graph);
|
|
- CombineVertex(graph);
|
|
|
|
|
|
+ var newCount = graph.GetBootVertexs().Count;
|
|
|
|
+ var oldCount = 0;
|
|
|
|
+ do
|
|
|
|
+ {
|
|
|
|
+ oldCount = newCount;
|
|
|
|
+ CombineVertex(graph);
|
|
|
|
+ newCount = graph.GetBootVertexs().Count;
|
|
|
|
+ //数量不变,算处理完
|
|
|
|
+ } while (oldCount != newCount);
|
|
|
|
+
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 附加节点信息
|
|
/// 附加节点信息
|
|
@@ -350,8 +359,9 @@ namespace SAGA.GplotRelationComputerManage
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 确定开始点
|
|
#region 确定开始点
|
|
- List<string> edgeIds = new List<string>();
|
|
|
|
- List<string> vertexIds = new List<string>();
|
|
|
|
|
|
+ HashSet<string> edgeIds = new HashSet<string>();
|
|
|
|
+ //点遍历id区分系 flowType信息
|
|
|
|
+ HashSet<string> vertexIds = new HashSet<string>();
|
|
foreach (var systemVertex in vertexes)
|
|
foreach (var systemVertex in vertexes)
|
|
{
|
|
{
|
|
if (vertexIds.Contains(systemVertex.Id))
|
|
if (vertexIds.Contains(systemVertex.Id))
|
|
@@ -383,14 +393,16 @@ namespace SAGA.GplotRelationComputerManage
|
|
}
|
|
}
|
|
Queue<SystemVertex> queueVertexes = new Queue<SystemVertex>();
|
|
Queue<SystemVertex> queueVertexes = new Queue<SystemVertex>();
|
|
queueVertexes.Enqueue(systemVertex);
|
|
queueVertexes.Enqueue(systemVertex);
|
|
|
|
+ Func<string, string> commonId = (str) => useFlowType + "_" + str ;
|
|
while (queueVertexes.Any())
|
|
while (queueVertexes.Any())
|
|
{
|
|
{
|
|
var currentVertex = queueVertexes.Dequeue();
|
|
var currentVertex = queueVertexes.Dequeue();
|
|
- if (vertexIds.Contains(currentVertex.Id))
|
|
|
|
|
|
+ //普通节点Id
|
|
|
|
+ if (vertexIds.Contains(commonId(currentVertex.Id)))
|
|
{
|
|
{
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- vertexIds.Add(currentVertex.Id);
|
|
|
|
|
|
+ vertexIds.Add(commonId(currentVertex.Id));
|
|
|
|
|
|
var edges = graph.GetInEdges(currentVertex.Id);
|
|
var edges = graph.GetInEdges(currentVertex.Id);
|
|
foreach (var systemEdge in edges)
|
|
foreach (var systemEdge in edges)
|
|
@@ -412,12 +424,9 @@ namespace SAGA.GplotRelationComputerManage
|
|
if ((isStart && systemEdge.ContainVertex(currentVertex.Id) == 1) || (!isStart && systemEdge.ContainVertex(currentVertex.Id) == 0))
|
|
if ((isStart && systemEdge.ContainVertex(currentVertex.Id) == 1) || (!isStart && systemEdge.ContainVertex(currentVertex.Id) == 0))
|
|
{
|
|
{
|
|
systemEdge.Reverse();
|
|
systemEdge.Reverse();
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (!vertexIds.Contains(otherId))
|
|
|
|
|
|
+ }
|
|
|
|
+ if (!vertexIds.Contains(commonId(otherId)))
|
|
{
|
|
{
|
|
-
|
|
|
|
var nextVertex = graph.FindVertex(otherId);
|
|
var nextVertex = graph.FindVertex(otherId);
|
|
if (nextVertex != null)
|
|
if (nextVertex != null)
|
|
{
|
|
{
|
|
@@ -527,6 +536,145 @@ namespace SAGA.GplotRelationComputerManage
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 确定流向
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="graph"></param>
|
|
|
|
+ private void DirectedEdge3(SystemGraph graph)
|
|
|
|
+ {
|
|
|
|
+ #region 加载边的系统信息
|
|
|
|
+ var originEdges = graph.Edges.Where(e => !e.Children.Any()).ToList();
|
|
|
|
+ foreach (var originEdge in originEdges)
|
|
|
|
+ {
|
|
|
|
+ var refElements = originEdge.Data;
|
|
|
|
+ //获取边系统类型
|
|
|
|
+ originEdge.SystemName = (refElements.FirstOrDefault(e => e is MEPCurve) as MEPCurve)?.GetSystemTypeName();
|
|
|
|
+ //根据系统类型和特殊设备确定旁通和补水;未完,待续
|
|
|
|
+ var systemItem = Setting.RelationTypeShell.GetFirstMatchSystem(originEdge.SystemName);
|
|
|
|
+ if (systemItem != null)
|
|
|
|
+ {
|
|
|
|
+ originEdge.EdgeCategory = systemItem.ContainEdgeTypes.FirstOrDefault();
|
|
|
|
+ originEdge.FlowType = systemItem.FlowType == FlowType.In ? 2 : 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region 描述
|
|
|
|
+ /*
|
|
|
|
+ * 1、查找遍历起点
|
|
|
|
+ * 2、根据起点遍历所有的节点,并调整节点的顺序
|
|
|
|
+ */
|
|
|
|
+ #endregion
|
|
|
|
+ #region 获取定义端点
|
|
|
|
+ var vertexes = graph.GetBootVertexs().Where(v => SystemCalcUtil.IsStartValveName(v.GetEquipment()?.Name)).ToList();
|
|
|
|
+ if (!vertexes.Any())
|
|
|
|
+ return;
|
|
|
|
+ //将顶点按前缀分组
|
|
|
|
+ // Group
|
|
|
|
+ Dictionary<string, List<SystemVertex>> dicVertexes = new Dictionary<string, List<SystemVertex>>();
|
|
|
|
+ foreach (var systemVertex in vertexes)
|
|
|
|
+ {
|
|
|
|
+ var tempEdges = graph.GetInEdges(systemVertex.Id);
|
|
|
|
+ if (tempEdges.Any())
|
|
|
|
+ {
|
|
|
|
+ var item = systemVertex.GetEquipment();
|
|
|
|
+ if (item == null)
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (tempEdges.Any(e => e.FlowType == 2))
|
|
|
|
+ {
|
|
|
|
+ item.Name = "出口" + item.Id;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ item.Name = "入口" + item.Id;
|
|
|
|
+ }
|
|
|
|
+ // dicValues
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+ #region 确定开始点
|
|
|
|
+ HashSet<string> edgeIds = new HashSet<string>();
|
|
|
|
+ //点遍历id区分系 flowType信息
|
|
|
|
+ HashSet<string> vertexIds = new HashSet<string>();
|
|
|
|
+ foreach (var systemVertex in vertexes)
|
|
|
|
+ {
|
|
|
|
+ if (vertexIds.Contains(systemVertex.Id))
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ bool isStart = true;
|
|
|
|
+
|
|
|
|
+ var currentVertexName = systemVertex.GetEquipment().Name;
|
|
|
|
+ if (string.IsNullOrWhiteSpace(currentVertexName))
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var useFlowType = 0;
|
|
|
|
+ if (currentVertexName.Contains("入口"))
|
|
|
|
+ {
|
|
|
|
+ useFlowType = 1;
|
|
|
|
+ isStart = true;
|
|
|
|
+ }
|
|
|
|
+ else if (currentVertexName.Contains("出口"))
|
|
|
|
+ {
|
|
|
|
+ useFlowType = 2;
|
|
|
|
+ isStart = false;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Queue<SystemVertex> queueVertexes = new Queue<SystemVertex>();
|
|
|
|
+ queueVertexes.Enqueue(systemVertex);
|
|
|
|
+ Func<string, string> commonId = (str) => useFlowType + "_" + str;
|
|
|
|
+ while (queueVertexes.Any())
|
|
|
|
+ {
|
|
|
|
+ var currentVertex = queueVertexes.Dequeue();
|
|
|
|
+ //普通节点Id
|
|
|
|
+ if (vertexIds.Contains(commonId(currentVertex.Id)))
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ vertexIds.Add(commonId(currentVertex.Id));
|
|
|
|
+
|
|
|
|
+ var edges = graph.GetInEdges(currentVertex.Id);
|
|
|
|
+ foreach (var systemEdge in edges)
|
|
|
|
+ {
|
|
|
|
+ if (systemEdge.FlowType != useFlowType)
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (edgeIds.Contains(systemEdge.Id))
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ var otherId = systemEdge.GetAnotherVertex(currentVertex.Id);
|
|
|
|
+ if (vertexes.Any(v => v.Id == otherId))
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ edgeIds.Add(systemEdge.Id);
|
|
|
|
+ if ((isStart && systemEdge.ContainVertex(currentVertex.Id) == 1) || (!isStart && systemEdge.ContainVertex(currentVertex.Id) == 0))
|
|
|
|
+ {
|
|
|
|
+ systemEdge.Reverse();
|
|
|
|
+ }
|
|
|
|
+ if (!vertexIds.Contains(commonId(otherId)))
|
|
|
|
+ {
|
|
|
|
+ var nextVertex = graph.FindVertex(otherId);
|
|
|
|
+ if (nextVertex != null)
|
|
|
|
+ {
|
|
|
|
+ queueVertexes.Enqueue(nextVertex);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+ }
|
|
#endregion
|
|
#endregion
|
|
#endregion
|
|
#endregion
|
|
}
|
|
}
|