|
using Yw.WinFrmUI.HydroL3d;
|
|
namespace Yw.WinFrmUI
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public static class HydroL3dTransferHelper
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public static Network ToL3dNetworkViewModel(this Yw.Model.HydroModelInfo rhs)
|
{
|
if (rhs == null)
|
{
|
return default;
|
}
|
var vm = new Network();
|
if (rhs.Junctions != null && rhs.Junctions.Count > 0)
|
{
|
foreach (var junction in rhs.Junctions)
|
{
|
|
}
|
}
|
if (rhs.Nozzles != null && rhs.Nozzles.Count > 0)
|
{
|
foreach (var nozzle in rhs.Nozzles)
|
{
|
|
}
|
}
|
if (rhs.Hydrants != null && rhs.Hydrants.Count > 0)
|
{
|
foreach (var hydrant in rhs.Hydrants)
|
{
|
|
}
|
}
|
if (rhs.Elbows != null && rhs.Elbows.Count > 0)
|
{
|
foreach (var elbow in rhs.Elbows)
|
{
|
|
}
|
}
|
if (rhs.Threelinks != null && rhs.Threelinks.Count > 0)
|
{
|
foreach (var threelink in rhs.Threelinks)
|
{
|
|
}
|
}
|
if (rhs.Fourlinks != null && rhs.Fourlinks.Count > 0)
|
{
|
foreach (var fourlink in rhs.Fourlinks)
|
{
|
|
}
|
}
|
if (rhs.Meters != null && rhs.Meters.Count > 0)
|
{
|
foreach (var meter in rhs.Meters)
|
{
|
|
}
|
}
|
if (rhs.Flowmeters != null && rhs.Flowmeters.Count > 0)
|
{
|
foreach (var flowmeter in rhs.Flowmeters)
|
{
|
|
}
|
}
|
if (rhs.Pressmeters != null && rhs.Pressmeters.Count > 0)
|
{
|
foreach (var pressmeter in rhs.Pressmeters)
|
{
|
|
}
|
}
|
if (rhs.Bluntheads != null && rhs.Bluntheads.Count > 0)
|
{
|
foreach (var blunthead in rhs.Bluntheads)
|
{
|
|
}
|
}
|
|
if (rhs.Reservoirs != null && rhs.Reservoirs.Count > 0)
|
{
|
foreach (var reservoir in rhs.Reservoirs)
|
{
|
|
}
|
}
|
if (rhs.Tanks != null && rhs.Tanks.Count > 0)
|
{
|
foreach (var tank in rhs.Tanks)
|
{
|
|
}
|
}
|
if (rhs.Waterboxs != null && rhs.Waterboxs.Count > 0)
|
{
|
foreach (var waterbox in rhs.Waterboxs)
|
{
|
|
}
|
}
|
|
if (rhs.Pipes != null && rhs.Pipes.Count > 0)
|
{
|
foreach (var pipe in rhs.Pipes)
|
{
|
var startNode = rhs.GetAllNodes().Find(x => x.Code == pipe.StartCode);
|
var endNode = rhs.GetAllNodes().Find(x => x.Code == pipe.EndCode);
|
var pipeViewModel = new Pipe();
|
pipeViewModel.Id = pipe.Code;
|
pipeViewModel.Name = pipe.Name;
|
pipeViewModel.StartPosition = new Point3d(startNode.Position3d.X, startNode.Position3d.Y, startNode.Position3d.Z);
|
pipeViewModel.EndPosition = new Point3d(endNode.Position3d.X, endNode.Position3d.Y, endNode.Position3d.Z);
|
vm.Append(pipeViewModel, out _);
|
}
|
}
|
if (rhs.Translations != null && rhs.Translations.Count > 0)
|
{
|
foreach (var translation in rhs.Translations)
|
{
|
|
}
|
}
|
if (rhs.Exchangers != null && rhs.Exchangers.Count > 0)
|
{
|
foreach (var exchanger in rhs.Exchangers)
|
{
|
|
}
|
}
|
|
if (rhs.Pumps != null && rhs.Pumps.Count > 0)
|
{
|
foreach (var pump in rhs.Pumps)
|
{
|
|
}
|
}
|
if (rhs.Valves != null && rhs.Valves.Count > 0)
|
{
|
foreach (var valve in rhs.Valves)
|
{
|
|
}
|
}
|
|
return vm;
|
}
|
}
|
}
|