Pārlūkot izejas kodu

mxg:优化提取外轮廓速度。速度提升10倍

mengxiangge 5 gadi atpakaļ
vecāks
revīzija
51189c4507

+ 1 - 1
Dispatcher/Client/app.config

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <appSettings>
-    <add key="IP" value="47.94.18.1" />
+    <add key="IP" value="192.168.20.225" />
     <add key="Port" value="6666" />
     <add key="DownloadFileDir" value="E:\\" />
     <add key="MaxTaskCount" value="3" />

+ 18 - 18
Executer/DataExport/RevitToJBim/Extension/SpaceExtension.cs

@@ -103,19 +103,24 @@ namespace RevitToJBim.Extension
                 SpatialElementBoundaryOptions options = new SpatialElementBoundaryOptions();
                 //options.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish;
                 var segments = space.GetBoundarySegments(options);
-                double tolerance = space.Document.Application.ShortCurveTolerance;
+                Document doc = space.Document;
+                double tolerance = doc.Application.ShortCurveTolerance;
+                
                 foreach (var segment in segments)
                 {
                     #region 取外轮廓的点
 
                     List<XYZ> xyzs = new List<XYZ>();
+                    var allWalls = doc.GetElements<Wall>();
+                    var tupleWalls = allWalls
+                        .Select(t => new Tuple<Curve, Wall>(t.GetLocationCurve(), t)).ToList();
                     foreach (BoundarySegment boundarySegment in segment)
                     {
                         var segmentElement = space.Document.GetElement(boundarySegment.ElementId);
                         if (segmentElement is Wall wall)
                         {
                             var wallCurve = wall.GetLocationCurve();
-                            var parallelWalls = GetParallelWalls(wall);
+                            var parallelWalls = GetParallelWalls(wall, tupleWalls);
                             var segmentCurve = boundarySegment.GetCurve();
                             var tessellates = segmentCurve.Tessellate();
                             foreach (XYZ tessellate in tessellates)
@@ -188,31 +193,31 @@ namespace RevitToJBim.Extension
             return outlines;
         }
 
-        private static double m_RedundancySpace = 10d;
+        private static double m_RedundancySpace = 10d.ToApi();
         /// <summary>
         /// 获取平行墙,平行且投影有重叠部分
         /// </summary>
         /// <param name="wall"></param>
         /// <returns></returns>
-        public static List<Wall> GetParallelWalls(Wall wall)
+        public static List<Wall> GetParallelWalls(Wall wall, List<Tuple<Curve, Wall>> tupleWalls)
         {
             List<Wall> walls = new List<Wall>();
             walls.Add(wall);
-            var doc = wall.Document;
-            var allWalls = doc.GetElements<Wall>();
             var curve = wall.GetLocationCurve();
-            var parallelWalls = allWalls.Where(t => t.GetLocationCurve().IsParallel(curve));
+            var parallelWallTuples = tupleWalls.Where(t => t.Item1.IsParallel(curve));
 
             int len = walls.Count;
             do
             {
                 len = walls.Count;
-                foreach (Wall parallelWall in parallelWalls)
+                foreach (Tuple<Curve, Wall> parallelWallTuple in parallelWallTuples)
                 {
-                    var curve1 = parallelWall.GetLocationCurve();
+                    var curve1 = parallelWallTuple.Item1;
+                    var parallelWall = parallelWallTuple.Item2;
+
                     var startP11 = CurveExtend.StartPoint(curve1);
                     var endP11 = CurveExtend.EndPoint(curve1);
-                    double width1 = parallelWall.Width.FromApi();
+                    double width1 = parallelWall.Width;
                     for (int i = 0; i < walls.Count; i++)
                     {
                         Wall referenceWall = walls[i];
@@ -220,16 +225,11 @@ namespace RevitToJBim.Extension
                         var curve2 = referenceWall.GetLocationCurve();
                         var startP12 = CurveExtend.GetProjectPt(curve2, startP11);
                         var endP12 = CurveExtend.GetProjectPt(curve2, endP11);
-                        var startP21 = CurveExtend.StartPoint(curve2);
-                        var endP21 = CurveExtend.EndPoint(curve2);
-                        var startP22 = CurveExtend.GetProjectPt(curve1, startP21);
-                        var endP22 = CurveExtend.GetProjectPt(curve1, endP21);
                         //判断是否有重叠部分
-                        if (startP12.IsOnCurve(curve2) || endP12.IsOnCurve(curve2) || startP22.IsOnCurve(curve1) ||
-                            endP22.IsOnCurve(curve1))
+                        if (startP12.IsOnCurve(curve2) || endP12.IsOnCurve(curve2))
                         {
-                            double width2 = referenceWall.Width.FromApi();
-                            double distacne = curve1.Distance(curve2).FromApi();
+                            double width2 = referenceWall.Width;
+                            double distacne = curve1.Distance(curve2);
                             if (distacne < (width1 + width2) / 2.0 + m_RedundancySpace)
                                 walls.Add(parallelWall);
                         }

+ 2 - 2
Starter/Starter/Program.cs

@@ -37,10 +37,10 @@ namespace ExportStart
             if (string.IsNullOrWhiteSpace(command))
             {
                 command = "DataExport";
-                command = "DataCheck";
+                //command = "DataCheck";
                 path = @"E:\导出测试\testSpace.rvt";
                 path = @"E:\导出测试\编码修改后模型v1203\热源系统图模型第一版V1129.rvt";
-                path = @"E:\527.rvt";
+                path = @"C:\Users\SAGACLOUD\Desktop\新建文件夹\b1-2172005.rvt";
                 JObject jObject=new JObject();
                 jObject.Add("ResultFileName", @"C:\Users\SAGACLOUD\AppData\Local\RevitService\Result_e26be2fd-2097-462b-bdd0-a2a86b616928.txt");
                 param = jObject.ToString();