diff --git a/src/Core/ModelSplitterManager.cs b/src/Core/ModelSplitterManager.cs index 64c384f..f004a6c 100644 --- a/src/Core/ModelSplitterManager.cs +++ b/src/Core/ModelSplitterManager.cs @@ -982,96 +982,6 @@ namespace NavisworksTransport } } - /// - /// 获取所有模型元素(支持深度限制)- 使用统一的深度遍历函数 - /// - private ModelItemCollection GetAllModelItems(int maxDepth = 1) - { - return GetItemsByDepthUnified(maxDepth); - } - - - /// - /// 通用属性预览分层方法(基于分组策略模式) - /// - private List PreviewSplitByAttribute(ModelItemCollection items, SplitConfiguration config, IGroupingStrategy strategy) - { - var results = new List(); - - try - { - // 属性分组阶段 (35-70%) - OnProgressChanged(new ProgressChangedEventArgs(40, $"正在分析 {items.Count} 个模型元素的{strategy.GroupTypeName}信息")); - - var groups = strategy.GroupItems(items, config); - LogManager.Info($"[分层管理器] {strategy.GroupTypeName}属性检测完成,发现 {groups?.Count ?? 0} 个{strategy.GroupTypeName}分组"); - - OnProgressChanged(new ProgressChangedEventArgs(70, $"{strategy.GroupTypeName}分组完成,发现 {groups?.Count ?? 0} 个{strategy.GroupTypeName}")); - - if (groups != null && groups.Count > 0) - { - // 生成预览结果阶段 (70-85%) - OnProgressChanged(new ProgressChangedEventArgs(75, $"正在生成{strategy.GroupTypeName}预览结果")); - - int processedGroups = 0; - foreach (var group in groups.Values) - { - var previewResult = new SplitPreviewResult - { - LayerName = SanitizeLayerName(group.GroupName), - LayerAttribute = GetAttributeDescription(config.Strategy, group.GroupName, group.Metadata), - Items = new ModelItemCollection() - }; - - // 添加模型项到集合中 - if (group.Items != null && group.Items.Count > 0) - { - previewResult.Items.AddRange(group.Items); - LogManager.Info($"[分层管理器] {strategy.GroupTypeName}预览结果已缓存模型项: {strategy.GroupTypeName}='{previewResult.LayerName}', 模型项数量={previewResult.Items.Count}"); - } - else - { - LogManager.Warning($"[分层管理器] {strategy.GroupTypeName}预览结果没有模型项: {strategy.GroupTypeName}='{previewResult.LayerName}'"); - } - - // 添加元数据 - previewResult.Metadata["Original" + strategy.GroupTypeName + "Name"] = group.OriginalName; - previewResult.Metadata[strategy.GroupTypeName + "Name"] = group.GroupName; - previewResult.Metadata["MaxDepth"] = config.MaxDepth; - - // 复制分组的自定义元数据 - foreach (var meta in group.Metadata) - { - previewResult.Metadata[meta.Key] = meta.Value; - } - - results.Add(previewResult); - - // 更新进度 - processedGroups++; - int progressPercent = 75 + (processedGroups * 10 / groups.Count); - OnProgressChanged(new ProgressChangedEventArgs(progressPercent, - $"已处理 {processedGroups}/{groups.Count} 个{strategy.GroupTypeName}分组")); - } - - OnProgressChanged(new ProgressChangedEventArgs(85, $"{strategy.GroupTypeName}预览结果生成完成,共 {results.Count} 个分层")); - } - else - { - OnProgressChanged(new ProgressChangedEventArgs(85, $"未检测到{strategy.GroupTypeName}信息")); - LogManager.Warning($"[分层管理器] 未检测到任何{strategy.GroupTypeName}信息"); - } - } - catch (Exception ex) - { - LogManager.Error($"[分层管理器] 按{strategy.GroupTypeName}属性预览失败: {ex.Message}", ex); - OnProgressChanged(new ProgressChangedEventArgs(35, $"{strategy.GroupTypeName}分析失败: {ex.Message}")); - throw; - } - - return results; - } - /// /// 智能遍历分层预览 - 边遍历边检查边停止的新算法 /// 替代原有的预收集模式,大幅提升预览性能 @@ -1755,13 +1665,11 @@ namespace NavisworksTransport progress.Update(0.3); // 直接使用预览结果中的项目,这些已经是展开的完整节点树 - // 不添加任何祖先路径,让 IsolateSpecificItems 自己处理 var itemsToIsolate = preview.Items; LogManager.Info($"[分层管理器] 准备隔离显示 {itemsToIsolate.Count} 个节点"); // 使用 VisibilityManager.IsolateSpecificItems 隔离显示 - // 这个方法会使用缓存优化,效率更高 bool isolateSuccess = VisibilityHelper.IsolateSpecificItems(itemsToIsolate); if (!isolateSuccess)