/*-------------------------------------------------------------------------
 * 功能描述：ParseVirtualWall
 * 作者：xulisong
 * 创建时间： 2019/6/25 17:54:31
 * 版本号：v1.0
 *  -------------------------------------------------------------------------*/

using Autodesk.Revit.DB;
using JBIM;
using JBIM.Component;
using JBIM.Definition;
using RevitExport.Export;
using RevitToJBim.Common;
using SAGA.RevitUtils.Extends;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RevitToJBim.ComponentParse
{
    [UsableParse]
    public class ParseVirtualWall : ParseBase
    {
        public override List<string> FastIndex()
        {
            return new List<string>() { typeof(CurveElement).FullName };
        }
        public override bool Match(ElementWrapper wrapper)
        {
            return wrapper.RefElement is CurveElement;
        }


        protected override List<BimId> ParseInner(ElementWrapper wrapper, JBimParseContext context)
        {
            if (!(wrapper.RefElement is CurveElement se))
            {
                return null;
            }
            VirtualWall jObject = new VirtualWall();
            ParseCore.AttachObject(jObject, wrapper);
            context.AddBimObject(jObject);
            //jObject.Location = ParseCore.GetLocation(se.Location);
            var locations = new List<JBIM.Definition.XYZ>();
            var useCurve = (se.Location as LocationCurve).Curve;
            locations.Add(BimConvert.ConvertToXYZ(useCurve.StartPoint()));
            locations.Add(BimConvert.ConvertToXYZ(useCurve.EndPoint()));
            jObject.Location = GeometryLocation.CreateLineLocation(locations);
            Polygon outLine = new Polygon(locations);
            jObject.OutLine.Add(outLine);
            return new List<BimId>() { jObject.Id };
        }

    }
}
