Kaynağa Gözat

Merge branch 'master' of https://git.dev.tencent.com/xuhuo1234/saga

mengxiangge 6 yıl önce
ebeveyn
işleme
9496083a49

+ 1 - 1
MBI/SAGA.GplotManage/RelationManager/RelationUploader.cs

@@ -73,7 +73,7 @@ namespace SAGA.GplotManage
             #endregion
             if (realtionItems!=null&&realtionItems.Any())
             {
-                var blocks = realtionItems.SplitBlock(1000);
+                var blocks = realtionItems.SplitBlock(10000);
                 foreach (var block in blocks)
                 {
                     //var jarry = JArray.FromObject(realtionItems);

+ 31 - 23
MBI/SAGA.RevitUtils/Extends/XYZExtend.cs

@@ -1689,7 +1689,8 @@ namespace SAGA.RevitUtils.Extends
             #endregion
             //以给定点,向x正方向做射线
             //线段端点在射线上的集合
-            List<XYZ> points = new List<XYZ>();
+            //List<XYZ> points = new List<XYZ>();
+            List<PointGroup> groups = new List<PointGroup>();
             //默认是偶数
             bool isEven = true;
             double baseX = inputPoint.X;
@@ -1717,23 +1718,8 @@ namespace SAGA.RevitUtils.Extends
                         }
                         else if (baseX.IsLess(minX))
                         {
-                            //凸字形形状
-                            //记录射线的两个交点
-                            points.Add(start);
-                            points.Add(end);
-                            #region 与射线共线处理
-                            List<Line> useLines = new List<Line>(lines);
-                            useLines.Remove(line);
-                            var extendStart = LineUtil.GetFirstPoint(useLines, start, p => !p.Y.IsEqual(start.Y));
-                            var extendEnd = LineUtil.GetFirstPoint(useLines, end, p => !p.Y.IsEqual(end.Y));
-                            if (extendStart.Y.IsLess(baseY) == extendEnd.Y.IsThan(baseY))
-                            {
-                                if (!extendStart.Y.IsEqual(baseY) && !extendEnd.Y.IsEqual(baseY))
-                                {
-                                    isEven = !isEven;
-                                }
-                            } 
-                            #endregion
+                            PointGroup.AddGroup(groups, new PointGroup() { start, end });
+
                         }
                         #endregion
                     }
@@ -1759,11 +1745,11 @@ namespace SAGA.RevitUtils.Extends
                             var intersectionPoint = new XYZ(useX, baseY,0);
                             if (start.IsEqual(intersectionPoint))
                             {
-                                points.Add(start);
+                                PointGroup.AddGroup(groups, new PointGroup() { start });
                             }
                             else if (end.IsEqual(intersectionPoint))
                             {
-                                points.Add(end);
+                                PointGroup.AddGroup(groups, new PointGroup() { end });
                             }
                             else
                             {
@@ -1775,10 +1761,32 @@ namespace SAGA.RevitUtils.Extends
                 }
             }
             //整理通过的端点
-            var validPoints = points.Distinct(new XyzEqualComparer());
-            if (validPoints.Count() % 2 == 1)
+            if (groups.Any())
             {
-                isEven = !isEven;
+                foreach (var group in groups)
+                {
+                    var usePoint = group.FirstOrDefault();
+                    var refLines = lines.Where(l => LineUtil.GetPosition(l, usePoint) != -1).ToList();
+                    if (refLines.Count < 2)
+                    {
+                        continue;
+                    }
+                    List<double> results = new List<double>();
+                    foreach (Line line in refLines)
+                    {
+                        List<Line> useLines = new List<Line>(lines);
+                        useLines.Remove(line);
+                        var extendPoint = LineUtil.GetFirstPoint(useLines, usePoint, p => !p.Y.IsEqual(usePoint.Y));
+                        results.Add(extendPoint.Y);
+                    }
+                    if (results[0].IsLess(baseY) == results[1].IsThan(baseY))
+                    {
+                        if (!results[0].IsEqual(baseY) && !results[1].IsEqual(baseY))
+                        {
+                            isEven = !isEven;
+                        }
+                    }
+                }
             }
             return isEven ? -1 : 1;
         }

+ 1 - 0
MBI/SAGA.RevitUtils/SAGA.RevitUtils.csproj

@@ -306,6 +306,7 @@
     <Compile Include="Utils\AxisRange.cs" />
     <Compile Include="Utils\LineUtil.cs" />
     <Compile Include="Utils\OutlineUtil.cs" />
+    <Compile Include="Utils\PointGroup.cs" />
     <Compile Include="Utils\Polygon.cs" />
     <Compile Include="Utils\PolygonUtil.cs" />
     <Compile Include="Utils\VectorUtil.cs" />

+ 65 - 0
MBI/SAGA.RevitUtils/Utils/PointGroup.cs

@@ -0,0 +1,65 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:PointGroup
+ * 作者:xulisong
+ * 创建时间: 2019/5/9 13:56:10
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using Autodesk.Revit.DB;
+using SAGA.RevitUtils.Extends;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.RevitUtils.Utils
+{
+    /// <summary>
+    /// 点集合
+    /// </summary>
+    public class PointGroup : List<XYZ>
+    {
+        public PointGroup()
+        { }
+
+        public PointGroup(IEnumerable<XYZ> points) : base(points)
+        {
+
+        }
+        public new bool Contains(XYZ point)
+        {
+            return this.Any(p => p.IsEqual(point));
+        }
+
+        #region 构建点分组
+        public static List<PointGroup> AddGroup(List<PointGroup> groups, PointGroup newGroup)
+        {
+            /* 每个点只可能在一个组里。
+             * 算法注意:先传入1,2点,在传入3,4点,这样就放在了组里
+             * 然后放入2,3点,这样就需要将两个分组合并成一个分组
+             */
+            List<List<XYZ>> useGroups = new List<List<XYZ>>();
+            #region 找出关联分组
+            foreach (var point in newGroup)
+            {
+                for (int i = 0; i < groups.Count; i++)
+                {
+                    var currentGroup = groups[i];
+                    if (currentGroup.Contains(point))
+                    {
+                        useGroups.Add(currentGroup);
+                        groups.RemoveAt(i);
+                        break;
+                    }
+                }
+            }
+            #endregion
+            useGroups.Add(newGroup);
+            var tempGroup = new PointGroup(useGroups.SelectMany(g => g).Distinct(new XyzEqualComparer()));
+            groups.Add(tempGroup);
+            return groups;
+        }
+        #endregion
+    }
+}