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);
    }
}
