Jelajahi Sumber

mxg:整理代码

mengxiangge 6 tahun lalu
induk
melakukan
2480d3904c

File diff ditekan karena terlalu besar
+ 283 - 280
MBI/SAGA.DotNetUtils/Geometry/Geometry2d.cs


+ 1 - 1
MBI/SAGA.MBI/TestCommand.cs

@@ -119,7 +119,7 @@ namespace SAGA.MBI
                         double maxz = spaceVertex.Max(t => t.Z);
                         //if (z.IsBetween(minz, maxz))
                         {
-                            if(Geometry2D.InSidePolygon(spaceVertex.Count,spaceVertex.Select(t=>t.ToPointD()).ToArray(),point)!=2)
+                            if(Geometry2D.InSidePolygon(spaceVertex.Select(t=>t.ToPointD()).ToArray(),point)!=2)
                             //if (xyz.PointInPolygonByRay(spaceVertex) != -1)
                             {
                                 gcount++;

+ 57 - 11
MBI/SAGA.MBI/ToolCommand.cs

@@ -16,6 +16,7 @@ using Autodesk.Revit.DB.Plumbing;
 using Autodesk.Revit.UI;
 using FWindSoft.DataFramework;
 using SAGA.DotNetUtils;
+using SAGA.DotNetUtils.Geometry;
 using SAGA.DotNetUtils.Logger;
 using SAGA.DotNetUtils.Others;
 using SAGA.MBI.Common;
@@ -37,7 +38,7 @@ namespace SAGA.MBI
 {
 
     #region 工具
-    
+
     /// <summary>
     /// 立管对齐
     /// </summary>
@@ -50,7 +51,7 @@ namespace SAGA.MBI
             try
             {
                 int count = 0;
-                WinSelectCheckFloors win =new WinSelectCheckFloors();
+                WinSelectCheckFloors win = new WinSelectCheckFloors();
                 if (win.ShowDialog() == true)
                 {
                     VerticalPipeAlign.Instance.Execute();
@@ -87,15 +88,15 @@ namespace SAGA.MBI
                 switch (tip)
                 {
                     case DialogResult.Yes:
-                        count=DelZeroSpace.OperateAll();
+                        count = DelZeroSpace.OperateAll();
                         break;
                     case DialogResult.No:
-                        count=DelZeroSpace.OperateCurFloor();
+                        count = DelZeroSpace.OperateCurFloor();
                         break;
                     default:
                         break;
                 }
-                if(tip== DialogResult.Yes||tip== DialogResult.No)
+                if (tip == DialogResult.Yes || tip == DialogResult.No)
                     MessageShowBase.Infomation($"此次操作共删除{count}个空间");
 
             }
@@ -123,9 +124,54 @@ namespace SAGA.MBI
         {
             try
             {
-                var fi = ExternalDataWrapper.Current.UiApp.GetSelectedElement() as FamilyInstance;
+                List<Geometry2D.PointD> newPoints = new List<Geometry2D.PointD>();
+                newPoints.Add(new Geometry2D.PointD(0, 0));
+                newPoints.Add(new Geometry2D.PointD(400, 0));
+                newPoints.Add(new Geometry2D.PointD(400, 400));
+                newPoints.Add(new Geometry2D.PointD(200, 200));
+                newPoints.Add(new Geometry2D.PointD(0, 400));
+
+                //外点
+                var testPoint = new Geometry2D.PointD(-100, 200);
+                int flag = Geometry2D.InSidePolygon( newPoints.ToArray(),testPoint ); ;
+
+                var testPoint2 = new Geometry2D.PointD(50, 200);
+                int flag2 = Geometry2D.InSidePolygon(newPoints.ToArray(), testPoint2);
+
+                List<Geometry2D.PointD> newPoints2 = new List<Geometry2D.PointD>();
+                newPoints.Add(new Geometry2D.PointD(0, 0));
+                newPoints.Add(new Geometry2D.PointD(400, 0));
+                newPoints.Add(new Geometry2D.PointD(400, 400));
+                newPoints.Add(new Geometry2D.PointD(200, 600));
+                newPoints.Add(new Geometry2D.PointD(0, 400));
+                //外点
+                var testPoint3 = new Geometry2D.PointD(-100, 600);
+                int flag3 = Geometry2D.InSidePolygon(newPoints.ToArray(), testPoint); ;
+
+                var fi = commandData.Application.PickElement("请选择图元") as FamilyInstance;
+                if (fi == null) return Result.Succeeded;
                 var space = fi.GetReferenceSpace();
-                MessageShowBase.Infomation($"设备所在空间Id为{space?.Id}");
+                string str = "", str2 = "";
+                do
+                {
+                    if (space != null)
+                    {
+                        List<XYZ> spaceVertex = space.GetBoundaryVertexes().FirstOrDefault();
+                        if (spaceVertex == null)
+                        {
+                            str = "Boundary 为Null";
+                            break;
+                        }
+
+                        var xyz = fi.GetLocationPointMBIXYZ();
+                        str = "Geometry Intersection Result:" + xyz.PointInPolygonByRay(spaceVertex);
+
+                        str2 = "Geometry2D Intersection Result:" + Geometry2D.InSidePolygon(
+                                   spaceVertex.Select(t => t.ToPointD()).ToArray(), xyz.ToPointD());
+                    }
+
+                } while (false);
+                MessageShowBase.Infomation($"设备所在空间Id为{space?.Id}" + "\r\n" + $"{str}" + "\r\n" + $"{str2}");
             }
             catch (Exception e)
             {
@@ -541,7 +587,7 @@ namespace SAGA.MBI
     [Regeneration(RegenerationOption.Manual)]
     public class AddSiSpaceCommand : ExternalCommand
     {
-       
+
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
             List<string> errorIds = new List<string>();
@@ -578,12 +624,12 @@ namespace SAGA.MBI
                                 }
                             }
                         }
-                       
+
                     }
-                    MessageBox.Show("总共修改:"+totalIds.Count);
+                    MessageBox.Show("总共修改:" + totalIds.Count);
                     if (errorIds.Any()) ;
                     {
-                        MessageBox.Show("错误Ids:" + string.Join(";",errorIds));
+                        MessageBox.Show("错误Ids:" + string.Join(";", errorIds));
                     }
                 }
             }

File diff ditekan karena terlalu besar
+ 0 - 1361
MBI/SAGA.RevitUtils/Geometry/Geometry2D.cs


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

@@ -256,7 +256,6 @@
     <Compile Include="ExtensibleStorage\EnumDefination.cs" />
     <Compile Include="Geometry\EdgeInfo.cs" />
     <Compile Include="Geometry\Geometry.cs" />
-    <Compile Include="Geometry\Geometry2D.cs" />
     <Compile Include="Information.cs" />
     <Compile Include="Infrastructure\DoubleCompare.cs" />
     <Compile Include="Infrastructure\XYZByQuadrantCompare.cs" />