TellmePdmsPluging/Models/ShrinkwrapModelRequest.cs
sladro 8f5bcc0c98 添加模型缩减和项目打开功能的API支持
- 在HttpServer中实现了新的API端点:/api/project/open和/api/model/shrinkwrap
- 添加了ShrinkwrapModel和OpenProject命令的处理逻辑
- 在PdmsManager中实现了ShrinkwrapModel和OpenProject方法,支持相应请求的处理
- 更新了项目文件以包含新的命令和模型请求类

此更新增强了插件的功能,允许用户通过API进行模型缩减和项目打开操作。
2026-02-05 08:22:42 +08:00

103 lines
2.8 KiB
C#

using System.Collections.Generic;
namespace TellmePdmsPluging.Models
{
public class ShrinkwrapModelRequest
{
public bool DryRun { get; set; } = true;
public double Padding { get; set; } = 500.0;
public double TouchTolerance { get; set; } = 1.0;
public List<string> ZoneFilters
{
get { return _zoneFilters; }
set { _zoneFilters = NormalizeList(value); }
}
public List<string> KeepTypes
{
get { return _keepTypes; }
set { _keepTypes = NormalizeList(value); }
}
private List<string> _zoneFilters;
private List<string> _keepTypes;
public void ApplyDefaults()
{
if (_keepTypes == null || _keepTypes.Count == 0)
{
_keepTypes = new List<string> { "SITE", "ZONE", "STRU", "FRAME", "SHELL", "PLAT", "WALL" };
}
if (_zoneFilters == null)
{
_zoneFilters = new List<string>();
}
}
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 ShrinkwrapModelResult
{
public bool Success { get; set; }
public bool DryRun { get; set; }
public double Padding { get; set; }
public int TotalVisited { get; set; }
public int RemovedCount { get; set; }
public int KeptCount { get; set; }
public int ShellKeptCount { get; set; }
public List<string> RemovedElements { get; set; } = new List<string>();
public List<string> Errors { get; set; } = new List<string>();
public List<string> ZoneSummaries { get; set; } = new List<string>();
public System.DateTime StartedAt { get; set; }
public System.DateTime CompletedAt { get; set; }
public string Message { get; set; }
}
}