130 lines
3.7 KiB
C#
130 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace TellmePdmsPluging.Models
|
|
{
|
|
public class SimplifyModelRequest
|
|
{
|
|
public string ExecutionId { get; set; }
|
|
public string execution_id { get { return ExecutionId; } set { ExecutionId = value; } }
|
|
|
|
public bool DryRun { get; set; } = false;
|
|
|
|
public bool SkipLinkedElements { get; set; } = false;
|
|
|
|
public List<string> ZoneFilters
|
|
{
|
|
get { return _zoneFilters; }
|
|
set { _zoneFilters = NormalizeList(value); }
|
|
}
|
|
|
|
public List<string> KeepTypes
|
|
{
|
|
get { return _keepTypes; }
|
|
set { _keepTypes = NormalizeList(value); }
|
|
}
|
|
|
|
public List<string> RemoveTypes
|
|
{
|
|
get { return _removeTypes; }
|
|
set { _removeTypes = NormalizeList(value); }
|
|
}
|
|
|
|
public ShellPaddingOptions BoundingShell { get; set; } = new ShellPaddingOptions();
|
|
|
|
private List<string> _zoneFilters;
|
|
private List<string> _keepTypes;
|
|
private List<string> _removeTypes;
|
|
|
|
public void ApplyDefaults()
|
|
{
|
|
if (_keepTypes == null || _keepTypes.Count == 0)
|
|
{
|
|
_keepTypes = new List<string> { "SITE", "ZONE", "STRU", "FRAME", "SHELL", "PLAT", "WALL" };
|
|
}
|
|
|
|
if (_removeTypes == null || _removeTypes.Count == 0)
|
|
{
|
|
_removeTypes = new List<string> { "PIPE", "BRAN", "ELBO", "VALV", "FITT", "NOZZ", "EQUI" };
|
|
}
|
|
|
|
if (_zoneFilters == null)
|
|
{
|
|
_zoneFilters = new List<string>();
|
|
}
|
|
|
|
if (BoundingShell == null)
|
|
{
|
|
BoundingShell = new ShellPaddingOptions();
|
|
}
|
|
}
|
|
|
|
private static List<string> NormalizeList(IEnumerable<string> source)
|
|
{
|
|
if (source == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
var normalized = new List<string>();
|
|
|
|
foreach (var item in source)
|
|
{
|
|
if (IsNullOrWhiteSpace(item))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var formatted = item.Trim().ToUpperInvariant();
|
|
if (!normalized.Contains(formatted))
|
|
{
|
|
normalized.Add(formatted);
|
|
}
|
|
}
|
|
|
|
return normalized;
|
|
}
|
|
|
|
private static bool IsNullOrWhiteSpace(string value)
|
|
{
|
|
if (value == null)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
for (int i = 0; i < value.Length; i++)
|
|
{
|
|
if (!char.IsWhiteSpace(value[i]))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public class ShellPaddingOptions
|
|
{
|
|
public double Padding { get; set; } = 0d;
|
|
}
|
|
}
|
|
|
|
public class SimplifyModelResult
|
|
{
|
|
public bool Success { get; set; }
|
|
public bool DryRun { get; set; }
|
|
public bool SkipLinkedElements { get; set; }
|
|
public int TotalVisited { get; set; }
|
|
public int RemovedCount { get; set; }
|
|
public int KeptCount { get; set; }
|
|
public int SkippedLinkedCount { get; set; }
|
|
public List<string> RemovedElements { get; set; } = new List<string>();
|
|
public List<string> SkippedLinkedElements { get; set; } = new List<string>();
|
|
public List<string> Errors { get; set; } = new List<string>();
|
|
public DateTime StartedAt { get; set; }
|
|
public DateTime CompletedAt { get; set; }
|
|
public string Message { get; set; }
|
|
public List<string> ZoneSummaries { get; set; } = new List<string>();
|
|
}
|
|
}
|