/*-------------------------------------------------------------------------
 * 功能描述:ParseWall
 * 作者:xulisong
 * 创建时间: 2019/6/25 17:53:27
 * 版本号:v1.0
 *  -------------------------------------------------------------------------*/

using Autodesk.Revit.DB;
using JBIM;
using RevitExport.Export;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JBIM.Definition;
using RevitToJBim.Common;
using JWall = JBIM.Component.Wall;
namespace RevitToJBim.ComponentParse
{
    [UsableParse]
    public class ParseWall : ParseBase
    {
        public override List<string> FastIndex()
        {
            return new List<string>() { typeof(Wall).FullName };
        }
        public override bool Match(ElementWrapper wrapper)
        {
            return wrapper.RefElement is Wall;
        }


        protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
        {
            if (!(wrapper.RefElement is Wall wall))
            {
                return null;
            }
            JWall jObject = new JWall();
            ParseCore.AttachObject(jObject, wrapper);
            context.AddBimObject(jObject);
            jObject.Location = ParseCore.GetLocation(wall.Location);
            var polygons = RevitUtil.GetWallPolygon(wall);
            //是否保持z为0的转换;
            foreach (var polygon in polygons)
            {               
                var outLine = new Polygon(BimConvert.ConvertToXYZs(polygon,true));
                StandardUtil.ArrangeLoop(outLine);
                jObject.OutLine.Add(outLine);
            }

            jObject.Width = wall.Width.FtToUse();

            return new List<BimId>() { jObject.Id };
        }

    }
}