无碰撞也保存数据库,生成碰撞报告
This commit is contained in:
parent
ec135d5469
commit
d1ae5c83f4
@ -1519,42 +1519,36 @@ namespace NavisworksTransport.Core.Animation
|
||||
// 检查此动画配置是否已经进行过碰撞检测
|
||||
if (!_completedCollisionTests.Contains(_currentAnimationHash))
|
||||
{
|
||||
if (_allCollisionResults.Count > 0)
|
||||
LogManager.Info($"此动画配置首次完成,开始创建碰撞测试汇总(基于 {_allCollisionResults.Count} 个预计算碰撞记录)...");
|
||||
|
||||
// 🔥 设置等待光标,避免进度条关闭后的无响应
|
||||
var oldCursor = System.Windows.Input.Mouse.OverrideCursor;
|
||||
System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
|
||||
|
||||
try
|
||||
{
|
||||
LogManager.Info($"此动画配置首次完成,开始创建碰撞测试汇总(基于 {_allCollisionResults.Count} 个预计算碰撞记录)...");
|
||||
|
||||
// 🔥 设置等待光标,避免进度条关闭后的无响应
|
||||
var oldCursor = System.Windows.Input.Mouse.OverrideCursor;
|
||||
System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
|
||||
|
||||
try
|
||||
{
|
||||
// 🔥 使用用户设置的检测容差(米)
|
||||
ClashDetectiveIntegration.Instance.CreateAllAnimationCollisionTests(
|
||||
_allCollisionResults,
|
||||
_detectionTolerance,
|
||||
_pathName,
|
||||
_currentRouteId,
|
||||
_animatedObject,
|
||||
_isVirtualVehicle,
|
||||
_animationFrameRate,
|
||||
_animationDuration,
|
||||
_virtualVehicleLength,
|
||||
_virtualVehicleWidth,
|
||||
_virtualVehicleHeight,
|
||||
_pathPoints
|
||||
);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// 恢复光标
|
||||
System.Windows.Input.Mouse.OverrideCursor = oldCursor;
|
||||
}
|
||||
// 🔥 使用用户设置的检测容差(米)
|
||||
ClashDetectiveIntegration.Instance.CreateAllAnimationCollisionTests(
|
||||
_allCollisionResults,
|
||||
_detectionTolerance,
|
||||
_pathName,
|
||||
_currentRouteId,
|
||||
_animatedObject,
|
||||
_isVirtualVehicle,
|
||||
_animationFrameRate,
|
||||
_animationDuration,
|
||||
_virtualVehicleLength,
|
||||
_virtualVehicleWidth,
|
||||
_virtualVehicleHeight,
|
||||
_pathPoints
|
||||
);
|
||||
}
|
||||
else
|
||||
finally
|
||||
{
|
||||
LogManager.Info("无碰撞数据,跳过碰撞测试创建");
|
||||
// 恢复光标
|
||||
System.Windows.Input.Mouse.OverrideCursor = oldCursor;
|
||||
}
|
||||
|
||||
_completedCollisionTests.Add(_currentAnimationHash); // 记录此配置已完成碰撞检测
|
||||
LogManager.Info($"碰撞测试汇总已创建并记录,此配置后续播放将跳过碰撞检测");
|
||||
}
|
||||
|
||||
@ -500,12 +500,6 @@ namespace NavisworksTransport
|
||||
IsModelItemValid(collision.Item2)
|
||||
).ToList();
|
||||
|
||||
if (validCollisions.Count == 0)
|
||||
{
|
||||
LogManager.Warning("[ClashDetective] 没有有效的碰撞可以创建测试");
|
||||
return (null, null, 0);
|
||||
}
|
||||
|
||||
LogManager.Info($"[ClashDetective] 有效碰撞数量: {validCollisions.Count}");
|
||||
|
||||
// 第一步:创建主测试(不包含选择集,纯容器)
|
||||
@ -535,6 +529,29 @@ namespace NavisworksTransport
|
||||
return (null, null, 0);
|
||||
}
|
||||
|
||||
// 如果没有有效碰撞,直接保存空记录并返回
|
||||
if (validCollisions.Count == 0)
|
||||
{
|
||||
LogManager.Warning("[ClashDetective] 没有有效的碰撞,保存空碰撞记录");
|
||||
|
||||
// 保存到数据库
|
||||
SaveClashDetectiveResultToDatabase(
|
||||
pathName,
|
||||
routeId,
|
||||
new List<CollisionResult>(),
|
||||
frameRate,
|
||||
duration,
|
||||
detectionGap,
|
||||
animatedObject,
|
||||
isVirtualVehicle,
|
||||
virtualVehicleLength,
|
||||
virtualVehicleWidth,
|
||||
virtualVehicleHeight
|
||||
);
|
||||
|
||||
return (null, addedMainTest, 0);
|
||||
}
|
||||
|
||||
// 第二步:创建分组并添加碰撞结果(应用智能去重)
|
||||
// 1. 分组:按碰撞对象对分组
|
||||
var groupedCollisions = validCollisions
|
||||
@ -774,58 +791,46 @@ namespace NavisworksTransport
|
||||
{
|
||||
try
|
||||
{
|
||||
LogManager.Info($"=== 使用预计算碰撞数据创建ClashDetective测试(容差: {detectionGap}米) ===");
|
||||
|
||||
if (_documentClash == null || precomputedCollisions == null || precomputedCollisions.Count == 0)
|
||||
{
|
||||
LogManager.Info($"无预计算碰撞数据需要处理 - _documentClash: {_documentClash != null}, precomputedCollisions: {precomputedCollisions?.Count ?? 0}");
|
||||
return;
|
||||
}
|
||||
|
||||
LogManager.Info($"[预计算数据] 共有 {precomputedCollisions.Count} 个碰撞记录");
|
||||
|
||||
// 直接使用所有预计算结果,只过滤有效对象(不去重)
|
||||
var collisionResults = precomputedCollisions
|
||||
.Where(result => IsModelItemValid(result.Item1) && IsModelItemValid(result.Item2))
|
||||
.ToList();
|
||||
|
||||
if (collisionResults.Count == 0)
|
||||
{
|
||||
LogManager.Warning("没有有效的预计算碰撞可以创建测试");
|
||||
return;
|
||||
}
|
||||
|
||||
// 记录动画过程中的碰撞数量
|
||||
_animationCollisionCount = collisionResults.Count;
|
||||
LogManager.Info($"[预计算处理] 原始记录: {precomputedCollisions.Count},有效碰撞: {_animationCollisionCount}");
|
||||
|
||||
// 获取动画对象
|
||||
if (collisionResults.Count > 0)
|
||||
{
|
||||
animatedObject = collisionResults[0].Item1;
|
||||
}
|
||||
|
||||
var doc = Application.ActiveDocument;
|
||||
|
||||
// 调用公共方法运行ClashDetective测试并保存到数据库
|
||||
Progress progress = Application.BeginProgress("碰撞检测数据分析中,请稍候...");
|
||||
ClashTest addedMainTest = null;
|
||||
ClashResultGroup collisionGroup = null;
|
||||
int confirmedCount = 0;
|
||||
|
||||
try
|
||||
{
|
||||
var result = RunClashDetectiveTestsAndSaveToDatabase(
|
||||
precomputedCollisions,
|
||||
detectionGap,
|
||||
pathName,
|
||||
routeId,
|
||||
animatedObject,
|
||||
isVirtualVehicle,
|
||||
frameRate,
|
||||
duration,
|
||||
virtualVehicleLength,
|
||||
virtualVehicleWidth,
|
||||
LogManager.Info($"=== 使用预计算碰撞数据创建ClashDetective测试(容差: {detectionGap}米)===");
|
||||
|
||||
LogManager.Info($"[预计算数据] 共有 {precomputedCollisions.Count} 个碰撞记录");
|
||||
|
||||
// 直接使用所有预计算结果,只过滤有效对象(不去重)
|
||||
var collisionResults = precomputedCollisions
|
||||
.Where(result => IsModelItemValid(result.Item1) && IsModelItemValid(result.Item2))
|
||||
.ToList();
|
||||
|
||||
// 记录动画过程中的碰撞数量
|
||||
_animationCollisionCount = collisionResults.Count;
|
||||
LogManager.Info($"[预计算处理] 原始记录: {precomputedCollisions.Count},有效碰撞: {_animationCollisionCount}");
|
||||
|
||||
// 获取动画对象
|
||||
if (collisionResults.Count > 0)
|
||||
{
|
||||
animatedObject = collisionResults[0].Item1;
|
||||
}
|
||||
|
||||
var doc = Application.ActiveDocument;
|
||||
|
||||
// 调用公共方法运行ClashDetective测试并保存到数据库
|
||||
Progress progress = Application.BeginProgress("碰撞检测数据分析中,请稍候...");
|
||||
ClashTest addedMainTest = null;
|
||||
ClashResultGroup collisionGroup = null;
|
||||
int confirmedCount = 0;
|
||||
|
||||
try
|
||||
{
|
||||
var result = RunClashDetectiveTestsAndSaveToDatabase(
|
||||
precomputedCollisions,
|
||||
detectionGap,
|
||||
pathName,
|
||||
routeId,
|
||||
animatedObject,
|
||||
isVirtualVehicle,
|
||||
frameRate,
|
||||
duration,
|
||||
virtualVehicleLength,
|
||||
virtualVehicleWidth,
|
||||
virtualVehicleHeight,
|
||||
progress
|
||||
);
|
||||
@ -1534,28 +1539,11 @@ namespace NavisworksTransport
|
||||
{
|
||||
LogManager.Info($"[批处理] 使用预计算碰撞数据创建ClashDetective测试(容差: {detectionGap}米)");
|
||||
|
||||
if (_documentClash == null || precomputedCollisions == null || precomputedCollisions.Count == 0)
|
||||
{
|
||||
LogManager.Info($"[批处理] 无预计算碰撞数据需要处理");
|
||||
return null;
|
||||
}
|
||||
|
||||
LogManager.Info($"[批处理] 共有 {precomputedCollisions.Count} 个碰撞记录");
|
||||
|
||||
// 过滤有效的碰撞
|
||||
var validCollisions = precomputedCollisions
|
||||
.Where(collision => IsModelItemValid(collision.Item1) && IsModelItemValid(collision.Item2))
|
||||
.ToList();
|
||||
|
||||
if (validCollisions.Count == 0)
|
||||
{
|
||||
LogManager.Warning("[批处理] 没有有效的预计算碰撞可以创建测试");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 记录动画过程中的碰撞数量
|
||||
_animationCollisionCount = validCollisions.Count;
|
||||
LogManager.Info($"[批处理] 原始记录: {precomputedCollisions.Count},有效碰撞: {_animationCollisionCount}");
|
||||
_animationCollisionCount = precomputedCollisions.Count;
|
||||
LogManager.Info($"[批处理] 预计算碰撞: {_animationCollisionCount}");
|
||||
|
||||
// 调用公共方法运行ClashDetective测试并保存到数据库
|
||||
var result = RunClashDetectiveTestsAndSaveToDatabase(
|
||||
|
||||
@ -1586,22 +1586,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
var animationManager = Core.Animation.PathAnimationManager.GetInstance();
|
||||
var hasAnimationCollisions = animationManager?.AllCollisionResults?.Count > 0;
|
||||
|
||||
// 如果当前动画没有碰撞数据,但CurrentTestName存在,说明是旧数据
|
||||
// 需要清空CurrentTestName,避免使用上一次的测试数据
|
||||
if (!hasAnimationCollisions && !string.IsNullOrEmpty(_clashIntegration?.CurrentTestName))
|
||||
{
|
||||
LogManager.Info("当前动画无碰撞数据,清空ClashDetectiveIntegration的CurrentTestName");
|
||||
_clashIntegration.ClearCurrentTestName();
|
||||
}
|
||||
|
||||
// 如果没有测试名称,创建一个临时的测试名称(用于无碰撞情况)
|
||||
if (string.IsNullOrEmpty(_clashIntegration?.CurrentTestName))
|
||||
{
|
||||
var tempTestName = $"无碰撞_{DateTime.Now:yyyyMMdd_HHmmss}";
|
||||
LogManager.Info($"创建临时测试名称用于无碰撞报告: {tempTestName}");
|
||||
_clashIntegration.SetCurrentTestName(tempTestName);
|
||||
}
|
||||
|
||||
// 统一使用GenerateCollisionReportCommand生成报告(无论有无碰撞)
|
||||
UpdateMainStatus($"正在生成碰撞报告...", -1, true);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user