diff --git a/src/PathPlanning/GridMapCacheKey.cs b/src/PathPlanning/GridMapCacheKey.cs index 244a51d..c230a63 100644 --- a/src/PathPlanning/GridMapCacheKey.cs +++ b/src/PathPlanning/GridMapCacheKey.cs @@ -9,14 +9,14 @@ namespace NavisworksTransport.PathPlanning { /// /// GridMap缓存键,用于标识唯一的GridMap生成配置 - /// 基于通道数据、车辆尺寸、网格尺寸等关键参数 + /// 基于所有物流属性构件、车辆尺寸、网格尺寸等关键参数 /// public class GridMapCacheKey : IEquatable { /// - /// 通道数据哈希值(所有可通行物流构件) + /// 物流数据哈希值(所有物流属性构件,包括通道、门、无关项等) /// - public string ChannelDataHash { get; set; } + public string LogisticsDataHash { get; set; } /// /// 边界范围哈希 @@ -46,10 +46,10 @@ namespace NavisworksTransport.PathPlanning /// /// 构造函数 /// - public GridMapCacheKey(string channelDataHash, string boundsHash, double cellSize, + public GridMapCacheKey(string logisticsDataHash, string boundsHash, double cellSize, double vehicleRadius, double safetyMargin, double vehicleHeight) { - ChannelDataHash = channelDataHash ?? throw new ArgumentNullException(nameof(channelDataHash)); + LogisticsDataHash = logisticsDataHash ?? throw new ArgumentNullException(nameof(logisticsDataHash)); BoundsHash = boundsHash ?? throw new ArgumentNullException(nameof(boundsHash)); CellSize = cellSize; VehicleRadius = vehicleRadius; @@ -65,7 +65,7 @@ namespace NavisworksTransport.PathPlanning if (other == null) return false; if (ReferenceEquals(this, other)) return true; - return ChannelDataHash == other.ChannelDataHash && + return LogisticsDataHash == other.LogisticsDataHash && BoundsHash == other.BoundsHash && Math.Abs(CellSize - other.CellSize) < 1e-6 && Math.Abs(VehicleRadius - other.VehicleRadius) < 1e-6 && @@ -89,7 +89,7 @@ namespace NavisworksTransport.PathPlanning unchecked { int hash = 17; - hash = hash * 23 + (ChannelDataHash?.GetHashCode() ?? 0); + hash = hash * 23 + (LogisticsDataHash?.GetHashCode() ?? 0); hash = hash * 23 + (BoundsHash?.GetHashCode() ?? 0); hash = hash * 23 + CellSize.GetHashCode(); hash = hash * 23 + VehicleRadius.GetHashCode(); @@ -104,21 +104,20 @@ namespace NavisworksTransport.PathPlanning /// public override string ToString() { - var channelPreview = ChannelDataHash != null ? - ChannelDataHash.Substring(0, Math.Min(8, ChannelDataHash.Length)) : + var logisticsPreview = LogisticsDataHash != null ? + LogisticsDataHash.Substring(0, Math.Min(8, LogisticsDataHash.Length)) : "NULL"; var boundsPreview = BoundsHash != null ? BoundsHash.Substring(0, Math.Min(8, BoundsHash.Length)) : "NULL"; - return $"GridMapKey[Ch={channelPreview}, Bounds={boundsPreview}, " + + return $"GridMapKey[Logistics={logisticsPreview}, Bounds={boundsPreview}, " + $"Cell={CellSize:F2}, VR={VehicleRadius:F1}m, SM={SafetyMargin:F1}m, VH={VehicleHeight:F1}m]"; } /// /// 根据参数生成GridMap缓存键 /// - /// Navisworks文档 /// 边界范围 /// 网格大小 /// 车辆半径(米) @@ -129,19 +128,19 @@ namespace NavisworksTransport.PathPlanning double cellSize, double vehicleRadius, double safetyMargin, double vehicleHeight) { - var channelDataHash = ComputeChannelDataHash(); + var logisticsDataHash = ComputeLogisticsDataHash(); var boundsHash = ComputeBoundsHash(bounds); - return new GridMapCacheKey(channelDataHash, boundsHash, cellSize, + return new GridMapCacheKey(logisticsDataHash, boundsHash, cellSize, vehicleRadius, safetyMargin, vehicleHeight); } /// - /// 计算通道数据哈希值 - /// 基于所有可通行物流构件的ID、属性、几何等信息 + /// 计算物流数据哈希值 + /// 基于所有物流属性构件(包括通道、门、无关项等)的ID、属性、几何等信息 /// - /// 通道数据哈希 - private static string ComputeChannelDataHash() + /// 物流数据哈希 + private static string ComputeLogisticsDataHash() { try { @@ -149,13 +148,13 @@ namespace NavisworksTransport.PathPlanning { var hashBuilder = new StringBuilder(); - // 获取所有可通行的物流模型项 - var allChannelItems = CategoryAttributeManager.GetAllTraversableLogisticsItems(); + // 获取所有有物流属性的模型项(不仅仅是可通行项) + var allLogisticsItems = CategoryAttributeManager.GetAllLogisticsItems(); // 按InstanceGuid排序确保一致性 - var sortedItems = allChannelItems.OrderBy(item => item.InstanceGuid.ToString()).ToList(); + var sortedItems = allLogisticsItems.OrderBy(item => item.InstanceGuid.ToString()).ToList(); - hashBuilder.Append($"ChannelCount:{sortedItems.Count}|"); + hashBuilder.Append($"LogisticsCount:{sortedItems.Count}|"); foreach (var item in sortedItems) { @@ -199,8 +198,8 @@ namespace NavisworksTransport.PathPlanning } catch (Exception ex) { - LogManager.Warning($"[通道哈希] 计算通道数据哈希失败: {ex.Message},使用时间戳标识"); - return $"CHANNEL_HASH_FAILED_{DateTime.Now.Ticks}"; + LogManager.Warning($"[物流哈希] 计算物流数据哈希失败: {ex.Message},使用时间戳标识"); + return $"LOGISTICS_HASH_FAILED_{DateTime.Now.Ticks}"; } }