- FaceInferToolPlugin now returns specific reasons: '未命中模型' or '表面过窄' - ViewModel handlers show FailureReason instead of generic '未命中有效表面' - Catch exceptions still pass through BuildFromFaceNormal error messages
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using Autodesk.Navisworks.Api;
|
|
|
|
namespace NavisworksTransport
|
|
{
|
|
/// <summary>
|
|
/// 快速取面结果。所有坐标为宿主坐标系。
|
|
/// </summary>
|
|
public class FaceInferResult
|
|
{
|
|
public Point3D HitPoint { get; }
|
|
public Vector3D Normal { get; }
|
|
public ModelItem ModelItem { get; }
|
|
public bool IsValid { get; }
|
|
public string FailureReason { get; }
|
|
|
|
public FaceInferResult(Point3D hitPoint, Vector3D normal, ModelItem modelItem)
|
|
{
|
|
HitPoint = hitPoint;
|
|
Normal = normal;
|
|
ModelItem = modelItem;
|
|
IsValid = modelItem != null;
|
|
FailureReason = null;
|
|
}
|
|
|
|
private FaceInferResult(string failureReason)
|
|
{
|
|
HitPoint = new Point3D();
|
|
Normal = new Vector3D();
|
|
ModelItem = null;
|
|
IsValid = false;
|
|
FailureReason = failureReason;
|
|
}
|
|
|
|
public static FaceInferResult Invalid { get; } = new FaceInferResult(new Point3D(), new Vector3D(), null);
|
|
|
|
public static FaceInferResult Failure(string reason) => new FaceInferResult(reason);
|
|
}
|
|
}
|