/*-------------------------------------------------------------------------
 * 功能描述：RevitUtil
 * 作者：xulisong
 * 创建时间： 2019/6/24 9:55:09
 * 版本号：v1.0
 *  -------------------------------------------------------------------------*/

using Autodesk.Revit.DB;
using SAGA.RevitUtils.Extends;
using SAGA.RevitUtils.Extends.Graphic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RevitToJBim.Common
{
    public class RevitUtil
    {
        /// <summary>
        /// 获取FamilyInstance顶面轮廓
        /// </summary>
        /// <param name="fi"></param>
        /// <returns></returns>
        public static List<XYZ> GetTopPolygon(FamilyInstance fi)
        {
            List<XYZ> path = new List<XYZ>();
            var faces = fi.GetOriginalFaces(XYZ.BasisZ);
            var topface = faces.FirstOrDefault();
            //传递的path中没有重复点
            if (topface != null)
            {
                var curves = topface.GetCurves();
                for (int i = 0; i < curves.Count; i++)
                {
                    var current = curves[i];
                    var points = current.GetPoints();
                    points.RemoveAt(points.Count - 1);
                    path.AddRange(points);
                }
            }

            return path;
        }
    }
}
